onItemClick&LT;字符串数组&GT; strings.xml中(不ListView控件/ ArrayList中) [英] onItemClick <string-array> strings.xml (not ListView/ArrayList)
本文介绍了onItemClick&LT;字符串数组&GT; strings.xml中(不ListView控件/ ArrayList中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对的strings.xml文件。所有条目上的ListView showen一个,现在我想就埃维项目的触摸/点击一个treatement。
我已经纠正这一code:
I have a on strings.xml file. All the entries are showen a on ListView, and now i want to make a treatement on evey item touch/click. I have righted this code:
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
>
>
> setListAdapter(ArrayAdapter.createFromResource(getApplicationContext(),
> R.array.tut_titles, R.layout.offresaffichage));
>
> }
>
> public void onItemClick(AdapterView<?> parent, View view,
> int position, long id) {
> final String[] links = getResources().getStringArray(R.array.tut_titles);
// what to do here?
如何检索有关该项目的位置,并从它启动另一个活动?
我鑫卡特约开关,案件,但不知道如何实现它。
谢谢回答。
How to retrieve item position on the and start another activity from it? I thinked about switch, case but don't know how implement it. Thanks for answering.
推荐答案
您可以使用您的参数列表的第二个INT在onItemClick方法:
You can use the second int of your parameter list in the onItemClick method :
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final String[] links = getResources().getStringArray(R.array.tut_titles);
String link = links[ position ];
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse( link ));
startActivity(i);
}//met
这篇关于onItemClick&LT;字符串数组&GT; strings.xml中(不ListView控件/ ArrayList中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文