Listview is located inside the TabActivity and I am unable to generate the click on listItem, try a lot of way but unable to accomplish the task, so, anybody can help. thank you.
Asked
Active
Viewed 2,940 times
1
-
2Please add some relevant code for us. – Kumar Bibek Jul 14 '11 at 10:55
-
it's according to the scenerio that i have mention... I am able to generate click event for the component in the listview but not for the whole listview.. – kamal_tech_view Jul 14 '11 at 11:23
4 Answers
5
Taking a new View then inflate it will resolve the problem in listview onClick in TabHost...!
public View getView(final int position, View convertView1, ViewGroup parent)
{
final ViewHolder holder;
final Context context;
View convertView = null;
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.file_display_binding, null);
holder = new ViewHolder();
System.out.println("inside efficient array");
holder.file_imgview = (ImageView)convertView.findViewById(R.id.file_icon_diplay);
convertView.setOnClickListener(new View.OnClickListener()
{
//@Override
public void onClick(View v)
{
}
}
}
}

Tejaswi Yerukalapudi
- 8,987
- 12
- 60
- 101

kamal_tech_view
- 4,235
- 4
- 28
- 49
-
great your solution worked for me, was trying to fix for so long. But it does not show pressed state. I dont want to create my own drawable, want to use exisitng of android – Vivek Khandelwal Feb 13 '12 at 13:20
-
4
Firstly, get your ListView from it's ID:
ListView lv = (ListView)findViewById(R.id.myListView);
Then, set its setOnItemClickListener like:
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3)
{
// TODO Auto-generated method stub
}
});

Khawar
- 5,197
- 4
- 28
- 52
-
What sort of items/row do you have in your ListView? What are the controls that you are having there? – Khawar Jul 14 '11 at 11:52
-
imageview textview and Button, it's on the tabActivity and for the progressDialog I have used the thread also, these is the actuall scenerio. – kamal_tech_view Jul 14 '11 at 12:08
-
Button is also a clickable Control and it can take over the control of the ListItem row. You can run a simple test by putting toasts in both's onClick/OnListItemClick i.e. ListView's itemClick and Button's OnClick. – Khawar Jul 14 '11 at 12:16
-
Well, if the other views are taking up focus, then you list would be clickable normally. You should set the views' focussable and foccusableInTouchMode property to false. – Kumar Bibek Jul 14 '11 at 12:18
-
no idea Bibek, it might be due to tabActivity or due to thread and handler it's not working... so, much in stuck.... – kamal_tech_view Jul 14 '11 at 13:59
2
lv.setOnItemClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Intent inttentEventDetails = new Intent(Home.this, EventDetails.class);
inttentEventDetails.putExtra("EventID", v.getId());
overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
TabGroupActivity pActivity = (TabGroupActivity)Home.this.getParent();
pActivity.startChildActivity("UpcomingEvents", inttentEventDetails);
}
});

Kamal
- 1,415
- 13
- 24
-
lv.setOnItemClickListener is not clickable, so, any suggestion for these – kamal_tech_view Jul 14 '11 at 11:44
-
Taking a new View then inflate it will resolve the problem in listview onClick in TabHost...! – kamal_tech_view Aug 01 '11 at 05:29
2
You must notice that when a custom ListView contains focusable elements, such as buttons or checkBoxes, the method onListItemClick may not work (I think it's the expected behaviour).
So you must remove the focus from these focusable elements and it shall do the trick. In other words, add the following commands to the focusable elements of your ListView:
android:focusable="false"
android:focusableInTouchMode="false"

marcelosalloum
- 3,481
- 4
- 39
- 63