I
I
Ilya Chernichkin2011-08-21 12:19:30
Android
Ilya Chernichkin, 2011-08-21 12:19:30

Value of item from Android ListView?

Good day, please help me
, there is the following code
lv2=(ListView)findViewById(R.id.lister); //get ListView
id lv2.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1, lv_arr));
lv2.setTextFilterEnabled(true);
lv2.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
String itemname = new Integer(position).toString();
String S = v.getContext() .toString();
Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:123"+S.substring(15,18)));
startActivity(dialIntent);
}
});
}
I need to get the value by clicking on a line in the
ListView

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2011-08-21
@INCWADRA

lv2=(ListView)findViewById(R.id.lister); //получаем идентификатор ListView
final ArrayAdapter<String> ad = new ArrayAdapter(this,android.R.layout.simple_list_item_1, lv_arr);
lv2.setAdapter(ad);
lv2.setTextFilterEnabled(true);
lv2.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
String value = ad.getItem(position); // Это то что вам надо
}
});
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question