Friday, April 26, 2013

[android help] How do I use Intents with ListView?


I know there are many solutions to solve this problem.


But it's not same case as that.


This is my java code.



package com.progme.sejong_bus;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class BUSActivity extends Activity {

ListView listView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bus);

String []data =
{"공통공지사항","101번 버스정보","102번 버스정보","103번 버스정보","104번 버스정보",
"105번 버스정보","106번 버스정보","107번 버스정보","108번 버스정보","109번 버스정보",
"110번 버스정보","111번 버스정보","112번 버스정보","113번 버스정보","114번 버스정보",
"115번 버스정보","116번 버스정보","117번 버스정보"};

listView = (ListView)findViewById(R.id.listview1);

ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, data);

listView.setAdapter(adapter);
}
}


and this is my XML code




xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#000000" >

android:id="@+id/listview1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="top"
android:layout_weight="1"
android:cacheColorHint="#000000"
android:dividerHeight="1dp"
android:divider="#FFFFFF" >






I want intent to each list.. but how can i select each list?


And what code that i have to use?



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...