[android-developers] Re: ListView not responding to Click or KeyPress
I re-post layout file and ListActivity implementation public class SimpleListActivity extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getListView().setAdapter(new SimpleAdapter()); getListView().setClickable(true); getListView().setFocusable(true); getListView().setFocusableInTouchMode(true); getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { Log.d("", "onListItem event received."); super.onListItemClick(l, v, position, id); } class SimpleAdapter extends BaseAdapter { private String items[] = { "item-1", "item-2", "item-3" }; public int getCount() { return items.length; } public Object getItem(int position) { return items[position]; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = SimpleListActivity.this.getLayoutInflater() .inflate(R.layout.list_item_complex, null); } return convertView; } @Override public boolean areAllItemsEnabled() { return true; } @Override public int getItemViewType(int position) { return 1; } @Override public int getViewTypeCount() { return 1; } } } ===Layout file = http://schemas.android.com/apk/res/android"; android:layout_height="60dip" android:layout_width="fill_parent" android:padding="3dip" android:gravity="center" android:id="@+id/list_item_complex" android:clickable="true" android:focusable="true" android:focusableInTouchMode="true" > On 1月26日, 下午4時23分, Bing Jin Lin wrote: > Hello > > I have the same problem, my ListActivity has overridden > onListItemClick method, > > But I can't see click event passed into the method when I click on > item, also highlight row is not shown. > > Follwing is my layout file for a row on ListView: it does not contain > any foucsable children. > > > http://schemas.android.com/apk/res/ > android" > android:layout_height="60dip" android:layout_width="fill_parent" > android:padding="3dip" android:gravity="center" android:id="@+id/ > list_item_complex" > android:clickable="true" android:focusable="true" > android:focusableInTouchMode="true"> > android:layout_height="fill_parent" > android:src="@drawable/icon" > android:layout_alignParentLeft="true" > android:layout_width="57dip" > android:focusableInTouchMode="false" > android:longClickable="false" > android:layout_alignWithParentIfMissing="true" > android:background="@android:color/transparent" > android:focusable="true" > android:clickable="false"> > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:textAppearance="@style/ListItemTitleText" > android:gravity="left|center_vertical" > android:layout_alignParentTop="true" > android:layout_toRightOf="@+id/ > list_item_1image" > android:layout_alignWithParentIfMissing="true" > android:layout_alignParentRight="true" > android:background="@android:color/transparent" > android:focusableInTouchMode="false" > android:longClickable="false" > android:linksClickable="false" android:focusable="true" > android:clickable="false"> > android:text
[android-developers] Re: ListView not responding to Click or KeyPress
Hello I have the same problem, my ListActivity has overridden onListItemClick method, But I can't see click event passed into the method when I click on item, also highlight row is not shown. Follwing is my layout file for a row on ListView: it does not contain any foucsable children. http://schemas.android.com/apk/res/ android" android:layout_height="60dip" android:layout_width="fill_parent" android:padding="3dip" android:gravity="center" android:id="@+id/ list_item_complex" android:clickable="true" android:focusable="true" android:focusableInTouchMode="true"> Sincerely yours B.J. On 1月6日, 上午9時15分, Ted wrote: > Hey! > I think I have the same problem, and I do not have any focusable > children. My layout for a Row in theListViewcontains: > > LinearLayout > | > +-- ImageView > | > +-- LinearLayout > | > +-- TextView > | > +-- TextView > | > +-- TextView > > and the Main activity is like this: > > > public class Main extends Activity > { > ArrayList nodes; > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) > { > requestWindowFeature(Window.FEATURE_NO_TITLE); > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > ArrayList nodes = new ArrayList(); > nodes.add(new Node("My name", "My text", "13:10", 0)); > > NodeRowAdapter nra = new NodeRowAdapter(this, nodes); > > ListViewlistView1 = (ListView) findViewById > (R.id.ListViewNodes); > listView1.setOnItemClickListener(new OnItemClickListener() { > > public void onItemClick(AdapterView parent, View view, int > position, long id) > { > System.out.println ("get onItem Click position= > "+position); > } > }); > listView1.setAdapter(nra); > }} > > > > It seems to me as nothing at all happens when I click the item in > theListView... > > On 4 Dec 2009, 19:43, Romain Guy wrote: > > > This is unnecessary. This problem will occur if your list item > > contains focusable children (like buttons, edittexts, etc.) > > > On Thu, Dec 3, 2009 at 4:20 PM, hwii77 wrote: > > > maybe maybe try this: Add android:clickable="true" (and > > > android:focusable="true") > > > > On Dec 2, 1:37 pm, n179911 wrote: > > >> Hi, > > > >> I have a simpleListViewin my layout.xml file. > > > >> > >> android:layout_width="fill_parent" > > >> android:layout_height="wrap_content" > > >> /> > > > >> And in my javacode, I add a setOnItemClickListener() to mylistview: > > > >>listView.setOnItemClickListener(new OnItemClickListener() { > > > >> public void onItemClick(AdapterView parent, View view, > > >> int position, long id) { > > >> System.out.println ("get onItem Click position= > > >> "+position); > > > >> } > > >> }); > > > >> But when I run on G1. I don't see any print out when I click an item on > > >> the > > >>ListViewon the phone. > > >> Or when I select an item using track ball and press CENTER. > > > >> Can you please tell me why to resolve my problem? > > > >> Thanks in advance. > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to android-developers@googlegroups.com > > > To unsubscribe from this group, send email to > > > android-developers+unsubscr...@googlegroups.com > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > > -- > > Romain Guy > > Android framework engineer > > romain...@android.com > > > Note: please don't send private questions to me, as I don't have time > > to provide private support. All such questions should be posted on > > public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: how to run emulator to get 1-1 pixel mapping with WVGA854
I have same problem, does anyone have any solutions? On 10月10日, 上午1時04分, x17y19 wrote: > How do I run the emulator with WVGA854 skin so I get a 1-1 mapping of > device to screen pixels ? > > The WVGA854/layout file has "width 480 height 854" but when I run the > emulator, I get these values for DeviceMetrics: > density = 1.5 > densityDpi = 240 > scaledDensity = 1.5 > heightPixels = 569 > widthPixels = 320 > xdpi = 240.0 > ydpi = 240.0 > > I'd like to run the emulator so that I see heightPixels/widthPixels > values > of 854/480 in the code. > > I tried playing with the -dpi-device option but doesn't seem to help. > > Thanks for any help. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en