0
在我的代码我想告诉的WebView和TextView的从RSS feed.Here列表是代码:列表项点击不起作用
public class VediolistfetchActivity extends Activity {
/** Called when the activity is first created. */
ListView Feed;
URL url;
String[] title = { " " }, image={""};
ArrayAdapter<String> adapter;
ArrayList<Home> homes = new ArrayList<Home>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Feed = (ListView) findViewById(R.id.list);
try {
SAXParserFactory saxPF = SAXParserFactory.newInstance();
SAXParser saxP = saxPF.newSAXParser();
XMLReader xmlR = saxP.getXMLReader();
url = new URL("http://www.powergroupbd.com/sweethome/videolist.xml");
RSSHandler myXMLHandler = new RSSHandler();
xmlR.setContentHandler(myXMLHandler);
xmlR.parse(new InputSource(url.openStream()));
ArrayList<String> GOTTitle = myXMLHandler.gotTitle();
ArrayList<String> GOTImage = myXMLHandler.gotImage();
title = new String[GOTTitle.size()];
image = new String[GOTImage.size()];
for (int i = 0; i < GOTTitle.size(); i++) {
Home home = new Home();
title[i] = GOTTitle.get(i).toString();
image[i] = GOTImage.get(i).toString();
home.openclose=GOTTitle.get(i);
home.imagehome=GOTImage.get(i);
homes.add(home);
}
HomeAdapter homeAdapter = new HomeAdapter(
VediolistfetchActivity.this, R.layout.list_catagory,
homes);
Feed.setAdapter(homeAdapter);
}
catch (Exception e) {
Toast.makeText(getApplicationContext(),
"Something Went Wrong, Please check your net connection",
Toast.LENGTH_LONG).show();
}
}
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
Log.i("List Click", "Yes");
String dtlHomeTitle = Feed.getItemAtPosition(arg2).toString();
Log.i("title", dtlHomeTitle);
}
}
这里是我的main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:divider="#000000"
android:scrollbars="none"
android:scrollingCache="true" />
</LinearLayout>
这里是listcatagory.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_width="1px"
android:layout_height="1px"
android:layout_weight="1" >
</ListView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="38"
android:orientation="vertical" >
<WebView
android:id="@+id/img"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingBottom="2dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="2dp"
android:scaleType="centerCrop"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="15"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textSize="20dp"
android:textStyle="bold"
android:paddingLeft="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="47"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
但是当我点击个人列表项没有什么happen..plz有人告诉我这是为什么会发生?
我只是添加OnItemClickLostener在我的代码就像你说的..和我的我要举杯当我点击item..but没有什么happend个人名单.. :(@覆盖 \t公共无效onItemClick(适配器视图>为arg0,查看ARG1,INT ARG2,长ARG3){ \t \t // TODO自动生成方法存根 \t \t字符串d = Feed.getItemAtPosition(ARG2)的ToString(); \t \t Toast.makeText(getApplicationContext(),d,Toast.LENGTH_LONG).show(); \t} – 2012-04-17 18:55:13
现在我编辑这个像你说..但没有什么是烤面包当我点击一个单独的项目.. :( – 2012-04-17 18:57:44
是我添加show ..但什么都不是烤面包当我点击 – 2012-04-17 19:03:51