I have an ExpandableListView where each parentView has an EditText (and a textview) in it. When i added the EditText to the Layout it would no longer let me click or expand the ExpandableListView, all focus just goes to the EditText. Is there a way to make both the EditText and the ExpandableListView itself be clickable? I want to be able to click the expandableListView to expand the list, and the EditText to be able to enter text.
Thanks
EDIT: added code of my group view
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.group_row, null);
}
TextView playerName = (TextView) convertView.findViewById(R.id.playerName);
playerName.setText(groupElements[groupPosition]);
final EditText holeScore = (EditText) convertView.findViewById(R.id.score);
holeScore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(scoreCard.this, "On CLick", Toast.LENGTH_SHORT).show();
holeScore.setFocusable(true);
}
});
return convertView;
}
The problem is because of EditText's default focusablitiy. Since they are capable of getting focused by default this will make your parent view to be unfocused. So what you have to do is remove the focus capability of your EditText by using,
andorid:focusable="false".
And similarly if you are having any button in your parent, setting focusable false to it also will help. This is the only way you can make your parent view to get clicked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With