OnClickListener in my ListView

by plexus » Wed, 10 Mar 2010 04:35:17 GMT


Sponsored Links
 ow do I add a listner to the list... please show with code

=======
JAVA
=======
public class VelgKomponent extends ListActivity implements
OnClickListener{
String[] listItems = { "exploring", "android", "list", "activities",
"1",
"2", "3", "4" };

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.velgkomp);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
listItems));
getListView().setTextFilterEnabled(true);
//
findViewById(android.R.layout.simple_list_item_1).setOnClickListener(this);

Button bTilbake = (Button) findViewById(R.id.bTilbake);
bTilbake.setOnClickListener(this);
}

@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(),
ShoppingBasket.class);
startActivity(intent);
}
}

========
XML
========
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Tilbake"
android:id="@+id/bTilbake"></Button>
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Velg komposisjon"
android:gravity="center"></
TextView>
<Button android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Endre"></Button>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout03"
android:layout_weight="1" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"></
ListView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView android:text="Dette er en test "
android:layout_width=



OnClickListener in my ListView

by SREEHARI » Wed, 10 Mar 2010 16:52:27 GMT


 Use onListItemClick(ListView list, View view,int position, long id)

REgards,

SREEHARI

--


Sponsored Links


Other Threads

1. how to get bytes for mp3 song that is playing by mediaplayer?

hi,

I am playing mp3 song from server using
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

is it possible to get bytes for this song from memory anyway?

regards,
hitendra gohil

-- 

2. Android License response 鈥淩espond normally鈥

I am implementing android license for a paid app. My app is uploaded
but not published. I was able to all test responses in dev settings,
except "Respond normally".

What is the expected behavior when response is set to espond
normally I sideloaded a dev build as as what I uploaded to publisher
account, the respond is "LICENSED". Am I able to test more by setting
response to be "Respond normally", for instance, simulating real use
case?

-- 

3. Blend buttons over the video layer

4. error with Trafficstats

5. WTCerita: Racun Android :)

6. USB flash drive detected but not mounted

7. Read send sms