Wednesday, February 19, 2014

There checkbox android listview and edittext, edittext not eject input box


There checkbox android listview and edittext, when the checkbox is checked edittext want is available, when unchecked unavailable. The results can not be ejected input box.
Tip the following :05-30 09:16:21.820: W / TextView (15726): TextView does not support text selection Action mode cancelled
..I hope heroes help look!

Code is as follows
 
package com.android.food;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;


public class Adpter extends BaseAdapter {
private List > data;
private LayoutInflater mylayoutInflater = null;
public Adpter (Context context, List > datafrom) {
data = datafrom;
this.mylayoutInflater = LayoutInflater.from (context);

}
public class ViewHolder {
public TextView number;
public TextView name;
public TextView danwei;
public RadioGroup radioGroup;
public EditText many;
public CheckBox radio0;
public RadioButton radio1;
public RadioButton radio2;
public RadioButton radio3;
public RadioButton radio4;
public RadioButton radio5;
public RadioButton radio6;
public RadioButton radio7;
public RadioButton radio8;
public RadioButton radio9;
public RadioButton radio10;

}

@ Override
public int getCount () {
/ / TODO Auto-generated method stub
return data.size ();
}

@ Override
public Object getItem (int position) {
/ / TODO Auto-generated method stub
return data.get (position);
}

@ Override
public long getItemId (int position) {
/ / TODO Auto-generated method stub
return position;
}

@ Override
public View getView (final int position, View convertView, ViewGroup parent) {
/ / TODO Auto-generated method stub
final ViewHolder holder = new ViewHolder ();
/ / Log.i ("data", data.get (position) toString ().);
/ / If (convertView == null) {
convertView = mylayoutInflater.inflate (R.layout.grain, null);

holder.number = (TextView) convertView.findViewById (R.id.number);
holder.name = (TextView) convertView.findViewById (R.id.name);
holder.danwei = (TextView) convertView.findViewById (R.id.danwei);
holder.many = (EditText) convertView.findViewById (R.id.many);
holder.radioGroup = (RadioGroup) convertView.findViewById (R.id.radioGroup1);
holder.radio0 = (CheckBox) convertView.findViewById (R.id.radio0);
holder.radio1 = (RadioButton) convertView.findViewById (R.id.radio1);
holder.radio2 = (RadioButton) convertView.findViewById (R.id.radio2);
holder.radio3 = (RadioButton) convertView.findViewById (R.id.radio3);
holder.radio4 = (RadioButton) convertView.findViewById (R.id.radio4);
holder.radio5 = (RadioButton) convertView.findViewById (R.id.radio5);
holder.radio6 = (RadioButton) convertView.findViewById (R.id.radio6);
holder.radio7 = (RadioButton) convertView.findViewById (R.id.radio7);
holder.radio8 = (RadioButton) convertView.findViewById (R.id.radio8);
holder.radio9 = (RadioButton) convertView.findViewById (R.id.radio9);
holder.radio10 = (RadioButton) convertView.findViewById (R.id.radio10);
convertView.setTag (holder);
holder.radio0.setChecked ((Boolean) data.get (position) get ("eat").);
holder.number.setText (data.get (position) get ("number") toString ()..);
holder.name.setText ((String) data.get (position) get ("name").);
holder.danwei.setText ((String) data.get (position) get ("danwei").);
holder.many.setText ((String) data.get (position) get ("many") toString ()..);
holder.many.setOnClickListener (new View.OnClickListener () {

@ Override
public void onClick (View v) {
/ / TODO Auto-generated method stub
Log.i ("data", "i am clicked");
Log.i ("data", "holder.many.isFocusable =" + holder.many.isFocusable ());
Log.i ("data", "holder.many.isEnabled =" + holder.many.isEnabled ());

}
});

final RadioButton [] radio = {
holder.radio1, holder.radio2, holder.radio3,
holder.radio4, holder.radio5, holder.radio6,
holder.radio7, holder.radio8, holder.radio9,
holder.radio10,
};
holder.radio0.setOnCheckedChangeListener (new OnCheckedChangeListener () {

@ Override
public void onCheckedChanged (CompoundButton buttonView,
boolean isChecked) {
/ / TODO Auto-generated method stub
. data.get (position) put ("eat", isChecked);
if (! isChecked) {
holder.radioGroup.setEnabled (false);
holder.radioGroup.setFocusable (false);
holder.radioGroup.clearCheck ();
for (RadioButton radionew: radio) {
radionew.setEnabled (false);
radionew.setFocusable (false);
}
holder.many.setFocusable (false);
holder.many.setEnabled (false);
holder.many.setText ("0");

}
else {
holder.many.setFocusable (true);
holder.many.setEnabled (true);
holder.many.setText ("0");

holder.radioGroup.setEnabled (true);
holder.radioGroup.setFocusable (true);
for (RadioButton radionew: radio) {
radionew.setEnabled (true);
radionew.setFocusable (true);
}

}
}

});
if (! holder.radio0.isChecked ()) {
holder.radioGroup.setEnabled (false);
holder.radioGroup.clearCheck ();
for (RadioButton radionew: radio) {
radionew.setEnabled (false);
radionew.setFocusable (false);
}
holder.many.setFocusable (false);
holder.many.setEnabled (false);
holder.many.setText ("0");
}


if ((Integer) data.get (position). get ("checkid")! = 0) {
holder.radioGroup.check ((Integer) data.get (position) get ("checkid").);
}


holder.many.addTextChangedListener (new TextWatcher () {

@ Override
public void afterTextChanged (Editable s) {
/ / TODO Auto-generated method stub

}

@ Override
public void beforeTextChanged (CharSequence s, int start, int count,
int after) {
/ / TODO Auto-generated method stub

}

@ Override
public void onTextChanged (CharSequence s, int start, int before,
int count) {
/ / TODO Auto-generated method stub
. data.get (position) put ("many", s);
}

});

holder.radioGroup.setOnCheckedChangeListener (new RadioGroup.OnCheckedChangeListener () {

@ Override
public void onCheckedChanged (RadioGroup group, int checkedId) {
/ / TODO Auto-generated method stub
. data.get (position) put ("checkid", checkedId);
int i = 0;
for (RadioButton radionew: radio) {
i + +;
if (radionew.isChecked ()) {
. data.get (position) put ("time", i);
}
}
}

});

return convertView;
}



}

<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Dinga own
Reply:
checkbox will be blocked listview item's click and focusable attribute can only respond when the user clicks the checkbox, and the corresponding listview item click event can not be obtained, it is recommended not to use the checkbox
Reply:
Habit, error logs to see, question to send a detailed log.
Reply:
Thank you for your suggestion, I first posted, O (∩ _ ∩) O ~ the future will be improved!
In fact, in this place, checkbox listener:
holder.radio0.setOnCheckedChangeListener (new OnCheckedChangeListener () {

@ Override
public void onCheckedChanged (CompoundButton buttonView,
boolean isChecked) {
/ / TODO Auto-generated method stub
. data.get (position) put ("eat", isChecked);
if (! isChecked) {
holder.radioGroup.setEnabled (false);
holder.radioGroup.setFocusable (false);
holder.radioGroup.clearCheck ();
for (RadioButton radionew: radio) {
radionew.setEnabled (false);
radionew.setFocusable (false);
}
holder.many.setFocusable (false);
holder.many.setEnabled (false);
holder.many.setText ("0");

}
else {
holder.many.setFocusable (true);
holder.many.setEnabled (true);
holder.many.setText ("0");

holder.radioGroup.setEnabled (true);
holder.radioGroup.setFocusable (true);
for (RadioButton radionew: radio) {
radionew.setEnabled (true);
radionew.setFocusable (true);
}

}
}

});
editText has made a response, and when the checkbox is selected when, edittext listeners can also react to events:
holder.many.setOnClickListener (new View.OnClickListener () {

@ Override
public void onClick (View v) {
/ / TODO Auto-generated method stub
Log.i ("data", "i am clicked");
Log.i ("data", "holder.many.isFocusable =" + holder.many.isFocusable ());
Log.i ("data", "holder.many.isEnabled =" + holder.many.isEnabled ());

}
});
You can also print out the information isFocusable isEnabled are true, is not eject input box.
Reply:
Pro, you can not eject the input box What does it mean?
Reply:
Is click EditText text input keyboard does not pop up get out
Reply:
In Log.i ("data", "i am clicked"); preceded
v.requestFocus ();


        


Reply:
references 6th Floor reply:
is click EditText does not get out of the pop-up keyboard to enter text


Tried useless
Reply:
reference to the 7th floor of replies:
in Log.i ("data", "i am clicked"); preceded
v.requestFocus ();

Tried useless
Reply:
reference to the 7th floor of replies:
in Log.i ("data", "i am clicked"); preceded
v.requestFocus ();

Tried useless
Reply:
1 Check your manifest see if it is set up does not pop up input method attributes.
2. You can try this when user click edit text.

InputMethodManager imm = (InputMethodManager) getSystemService (Context.INPUT_METHOD_SERVICE);
imm.showSoftInput (mMessageEditField, InputMethodManager.HIDE_NOT_ALWAYS);
Reply:
reference to the 11th floor of the reply:.
1 Check your manifest see if it is set up does not pop method of input attributes.
2. You can try this when user click edit text.

InputMethodManager imm = (InputMethodManager) getSystemService (Context.INPUT_METHOD_SERVICE);
imm.sho ......

Hello O (∩ _ ∩) O Thank you for answering!
This phenomenon is very strange,
1, is to click Edittext will prompt TextView does not support text selection. Action mode cancelled.
2, is isFocusable isEnabled are true, not bombs keyboard. But recall getview keyboard can pop up
3, I
holder.many.setFocusable (false);
holder.many.setEnabled (false);
To holder.many.setVisibility (View.INVISIBLE);
holder.many.setFocusable (true);
holder.many.setEnabled (true);
To holder.many.setVisibility (View.VISIBLE); This will pop up keyboard input, is not it, and properties set on it?
Reply:
setFocusable can get the focus is set, setEnabled is set is available, and can pop up keyboard input are directly related.
Reply:
reference to the second floor of the reply:
checkbox will be blocked listview item's click and focusable attribute can only respond when the user clicks the checkbox, while the corresponding item listview Can not get click event, it is recommended not to use the checkbox

Pop is not the focus of the problem. Similarly, if there is less focus button is button will get priority in the listview, then editText not get the focus, not bombs edit box, you do not have to do so in the listview button up? I used the listView in CheckBox, there editText, the solution is very simple, a code, you can set editText gets focus, listview corresponding item click event is also a way to get, because a little problem called the others do not use. . It hurts too much egg bar.
Reply:
reference to the second floor of the reply:
checkbox will be blocked listview item's click and focusable attribute can only respond when the user clicks the checkbox, while the corresponding item listview Can not get click event, it is recommended not to use the checkbox

Pop is not the focus of the problem. Similarly, if there is less focus button is button will get priority in the listview, then editText not get the focus, not bombs edit box, you do not have to do so in the listview button up? I used the listView in CheckBox, there editText, the solution is very simple, a code, you can set editText gets focus, listview corresponding item click event is also a way to get, because a little problem called the others do not use. . It hurts too much egg bar.
Reply:
reference to the second floor of the reply:
checkbox will be blocked listview item's click and focusable attribute can only respond when the user clicks the checkbox, while the corresponding item listview Can not get click event, it is recommended not to use the checkbox

Pop is not the focus of the problem. Similarly, if there is less focus button is button will get priority in the listview, then editText not get the focus, not bombs edit box, you do not have to do so in the listview button up? I used the listView in CheckBox, there editText, the solution is very simple, a code, you can set editText gets focus, listview corresponding item click event is also a way to get, because a little problem called the others do not use. . It hurts too much egg bar.
Reply:
This data is dynamic listview do? Then also get content edittext entered?

No comments:

Post a Comment