Focus on EditText in ListView when block descendants (Android)

please Don’t use setOnItemClickListener for item click .. i think that you should be use item view click inside adapter method convertView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, “click item”,Toast.LENGTH_LONG).show(); } }); Remove this from main list item layout android:descendantFocusability=”blocksDescendants” Thanks and enjoy this code !

Different row layouts in ListView

Implement the getItemViewType() and getViewTypeCount() for your adapter: @Override public int getViewTypeCount() { return 2; //return 2, you have two types that the getView() method will return, normal(0) and for the last row(1) } and: @Override public int getItemViewType(int position) { return (position == this.getCount() – 1) ? 1 : 0; //if we are at … Read more

ListView without ListActivity

I actually have an app with a listview below some TextViews and above two buttons, let me grab my code! Here’s my activity with listview below the textviews and above the buttons (with quite a bit removed for brevity): public class BNYDirectoryResults extends Activity{ public static String[] stuff; ListView list; BNYAdapter adapter; /** Called when … Read more

Populate list of custom view using ListFragment

I solved my problem (as system32 suggests on comment) creating a CustomArrayAdapter class, and setting it as the adapter for my listView. First I changed android:id=”@+id/listView1″ to android:id=”@android:id/list” in fragment.xml. CustomArrayAdapter.java public class CustomArrayAdapter extends ArrayAdapter<Menu> { Context context; public CustomArrayAdapter(Context context, int textViewResourceId, List<Menu> objects) { super(context, textViewResourceId, objects); // TODO Auto-generated constructor stub … Read more

ListFragment does not accept my layout

Create the layout file list_content.xml <?xml version=”1.0″ encoding=”utf-8″?> <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent”> <LinearLayout android:id=”@+id/progressContainer” android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”match_parent” android:visibility=”gone” android:gravity=”center”> <ProgressBar style=”?android:attr/progressBarStyleLarge” android:layout_width=”wrap_content” android:layout_height=”wrap_content” /> <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:textAppearance=”?android:attr/textAppearanceSmall” android:text=”” android:paddingTop=”4dip” android:singleLine=”true” /> </LinearLayout> <FrameLayout android:id=”@+id/listContainer” android:layout_width=”match_parent” android:layout_height=”match_parent”> <ListView android:id=”@android:id/list” android:layout_width=”match_parent” android:layout_height=”match_parent” android:drawSelectorOnTop=”false” /> <TextView android:id=”@+id/internalEmpty” android:layout_width=”match_parent” android:layout_height=”match_parent” android:gravity=”center” android:textAppearance=”?android:attr/textAppearanceLarge” /> </FrameLayout> </FrameLayout> Put this inside … Read more

How to add Three Level ListView in ExpandableListView in android

You can try my following sample code. I have posted my full project to GitHub Of course, you should modify more to meet all your requirements. For basic case, I only use the data source in the arrays.xml file. Hope this helps! arrays.xml: <resources> <string-array name=”items_array_expandable_level_one”> <item>Level 1.1</item> <item>Level 1.2</item> <item>Level 1.3</item> </string-array> <string-array name=”items_array_expandable_level_one_one_child”> … Read more

Android: Radio button in custom list view

Here are the key ideas when a RadioButton is checked we must call notifyDataSetChanged(), so that all views get updated. when a RadioButton is checked we must set a selectedPosition, to keep track of which RadioButton is selected Views are recycled inside ListViews. Therefore, their absolute position changes in the ListView. Therefore, inside ListAdapter#getView(), we … Read more