对Android的ListView的onClick监听器Simp

对Android的ListView的onClick监听器Simp

本文介绍了新增了对Android的ListView的onClick监听器SimpleAdapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有发现与搜索:(

I didn't found the solution with the search :(

我编程的应用程序阅读RSS提要。
我用一个ListView为把每一个饲料的屏幕标题和描述成2的TextView。我意识到了SimpleAdapter。

I'm programming an application for reading RSS feeds.
I'm using a listview for putting a screen title and description of every feed into 2 textview. I realized that with a SimpleAdapter.

在我的项目,我有2类:MainActivity和AsynkTask。在mainActivity我执行读取RSS,并将它们放入适配器和列表视图

In my project I have 2 classes: MainActivity and AsynkTask.In mainActivity I execute the asyncTask that reads RSS and puts them into the adapter and the listview

现在,我如何才能增加点击监听器的列表视图打开每一个进到浏览器?

Now, how can I add a click listener on the listview for opening every feed into the browser?

我希望我正确地解释这个问题,我很抱歉我很糟糕的英语!谢谢大家。

I hope that I've explained correctly the problem and I'm sorry for my very bad english!Thanks to all.

PS:如果你需要我的一些codeI将它张贴

PS: if you need some of my code i will post it.

推荐答案

在你MainActivity的onCreate方法,如果它是一个ListActivity,你需要得到引用你的列表视图像这样:

In the onCreate method of your MainActivity, if it's a ListActivity, you need to get a reference to your list view like so:

ListView lv = getListView();

然后点击监听器添加到它,像这样:

Then add a click listener to it like so:

lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {
  //Open the browser here
}

这篇关于新增了对Android的ListView的onClick监听器SimpleAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 01:30