According to ListView class defintion (see
http://developer.android.com/reference/android/widget/ListView.html), it
is a subclass of AdapterView. The latter has a method
setOnItemClickListener
<http://developer.android.com/reference/android/widget/AdapterView.html#setOnItemClickListener%28android.widget.AdapterView.OnItemClickListener%29>(AdapterView.OnItemClickListener
<http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html>
listener). So, you should be able to declare that your activity is
implementing an AdapterView.OnItemClickListener
<http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html>
interface and then you should be able to invoke
lista.setOnItemClickListener(this);
Sergey
David Fire wrote:
my adapter hasnt any method to set a listner
the first problem is i cant click on any item.
i cant change the item.
2010/1/30 Sergey Ten <[email protected]
<mailto:[email protected]>>
Should setOnItemClickListener
<http://developer.android.com/reference/android/widget/AdapterView.html#setOnItemClickListener%28android.widget.AdapterView.OnItemClickListener%29>(AdapterView.OnItemClickListener
<http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html>
listener) be used instead? Also, should the activity implement
AdapterView.OnItemClickListener and not View.OnClickListener?
David Fire wrote:
hi
i cant press any item on my listview nor in the emulator nor
in a real phone.
item layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox android:id="@+id/RuleEnable" android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" ></CheckBox>
<TextView android:id="@+id/RuleName"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=""
android:focusable="true" ></TextView>
</LinearLayout>
listview layout
<ListView android:id="@+id/Listado"
android:layout_width="fill_parent"
android:layout_height="250px"
android:isScrollContainer="true"
android:drawSelectorOnTop="false"
android:choiceMode="singleChoice"></ListView>
some code
public class GuiActivity extends Activity implements
View.OnClickListener,
OnItemClickListener{
.... //lista means list in spanish
lista = (ListView)findViewById(R.id.Listado);
RuleList = new ArrayList<SMSRule>();
loadRuleList();
adapter=new SMSRuleAdaptor(this,RuleList);
lista.setAdapter(adapter);
lista.setOnItemClickListener(this);
this method is never called
public void onItemClick(AdapterView<?> arg0, View arg1, int
arg2, long id) {
enable.setText("id: "+id);
}
--
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
[email protected]
<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]
<mailto:android-developers%[email protected]>
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
[email protected]
<mailto:[email protected]>
To unsubscribe from this group, send email to
[email protected]
<mailto:android-developers%[email protected]>
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en