android


ExpandableListView items in ChildItem Layout click


I had an ExpandableList where I used Adapter to populate it.
Each child has a layout , Click does not work on first click.
On First click entire row is selected on 2nd click individual item on child layout row is working . IS there a way in which child item layout row individual item click works on 1st click.
Code used is below for Click:
#Override
public boolean onChildClick(ExpandableListView parent, View v, final int groupPosition, final int childPosition, long id) {
TextView tv= (TextView) v.findViewById(R.id.r2c1);
/*tv.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
launchChildScreen();
return true;
}
});*/
tv.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.d("TAG", "Clicked on button in Expandable List");
Toast.makeText(getActivity(),"Clicked on Account TextView"+childPosition+"::"+groupPosition,Toast.LENGTH_LONG).show();
}
});
return true; // i
}
You are setting click listener in onChildClick so that your clicks are not working on first time. Initialize and set click listener of your TextView in getChildView. it should work,
#Override
public View getChildView(int groupPosition, int childPosition,
final boolean isLastChild, View convertView, final ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_row, null);
holder = new ViewHolder();
holder.txtName = (TextView) convertView.findViewById(R.id.txtName);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txtName.setText("your name");
// here set onclicklistner
holder.txtName.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
// write your code here
}
});
return convertView;
}

Related Links

getting google maps working on phone/tablet (no problem on emulator)
Adding radio button of customize listview in radio group
Hyperlink for textview in android
BitmapFactory.decodeStream always returns NULL
How To: Parcel a bitmap in Android
Android - Trace
where is the android.permission.INTERNET permission check point in Android?
Android: How to access a file in the SD Card
Android colors are “mixed” on phone, solid on tablet
Android: ListFragment always show init list on background
Return a specified data at row “index” from an SQLite query
Launching activity from another application not displaying the activity, but it is running
How to set an alarm in android java
How can I store a calendar data in database
Stopping a thread in an Android Service
Android: Download JPG if statement

Categories

HOME
ggplot2
telegram
dns
ecmascript-6
redux-form
angular-formly
flex
composite-primary-key
package
simulink
scripting
google-apps
rds
cq5
zip
bookmarks
echo
elasticsearch-5
sendgrid-api-v3
pattern-matching
google-schemas
php-5.6
intercom
pybossa
renjin
3nf
azure-powershell
firefox-addon
dimensional-modeling
charles
visual-glitch
imagemap
hta
exit
mongoid6
siri
syntax-highlighting
licensing
fractions
rpgle
ceylon
user-defined-functions
realm-mobile-platform
record
spring-security4
contacts
fiware-cygnus
protege4
lint
imagenet
amazon-ses
metawidget
p4merge
comparison-operators
apriori
procfile
reportservice2010
mschart
launchctl
lightning
zenhub
spring-data-couchbase
cpu-cache
renaming
restore
choice
slackware
actor-platform
lrs
greatest-n-per-group
hclust
swizzling
query-by-example
nio2
piracy-prevention
ons-api
viola-jones
typemock
branch-and-bound
openbabel
procedural-programming
cosine-similarity
execve
big-ip
appserver
jqmodal
memset
dot42
draw2d-js
clickbank
inputmismatchexception
cffile
neos-server
nevron
merb
insert-id
joomla3.1
extreme-programming
qtconcurrent
virtualpathprovider
relative
saxparseexception
xcelsius
google-floodlight
webdev.webserver
clrstoredprocedure
strsep
twitterizer
timertask
office-2007
hbm2java
echo3
mathematical-notation
cuda.net
asynchronous-wcf-call
software-lifecycle
todos
firefox-3
xslcompiledtransform

Resources

Encrypt Message