I used listview in fragment but I used list onItemClick
listener not working. My code below and how to perfect solution.
public class StoreProf
Add these properties in your custom xml file
android:focusableInTouchMode="false"
android:focusable="false"
for your TextView and ImageButton.
whenever you list item contains something like button then this type of problem comes. you should use a view holder in you adapter class.
private class ViewHolder{
ImageButton imagebutton;
TextView textView;
}
use it in your getview method. hope this will work for you.
Add this
android:descendantFocusability="blocksDescendants"
to the RelativeLayout in listItem.xml
.
I guess ImageButton
takes focus when you click on list row.
Edit:
Consider using a ViewHolder
pattern
Reference:
http://developer.android.com/training/improving-layouts/smooth-scrolling.html
Here you go: Use onActivityCreated() instead and use the code here:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
ListView lv1 = (ListView)getActivity().findViewById(R.id.myStore_listview);
adtstore = new MyListAdapter(getActivity().getApplicationContext());
lv.setAdapter(adtstore);
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
Toast.makeText(getActivity(), "Item clicked : " + position, Toast.LENGTH_SHORT).show();
}
});
}
Should work now.. :)