Android:ListView选项卡中的onClick事件

Android:ListView选项卡中的onClick事件,android,listview,android-tabhost,Android,Listview,Android Tabhost,我只是安卓世界的新手。 我试图在选项卡内或实际上在活动中添加ListView, 每个listview将显示另一个包含文本、图像等组件的视图。 该组件必须是动态的,将在源程序中设置 列表视图布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:

我只是安卓世界的新手。 我试图在选项卡内或实际上在活动中添加ListView, 每个listview将显示另一个包含文本、图像等组件的视图。 该组件必须是动态的,将在源程序中设置

列表视图布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="80dip"
    android:layout_height="?android:attr/listPreferredItemHeight" android:gravity="center">
    <ImageView android:id="@+id/img" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
    android:layout_height="fill_parent" >
    <TextView android:id="@+id/name" android:layout_width="fill_parent"
        android:layout_height="?android:attr/listPreferredItemHeight" android:textSize="18dip"
        android:paddingLeft="10dip" android:gravity="center_vertical" />
</LinearLayout>
您可以看到我正在尝试使用setImageResource和setText设置图像和文本, 但在我运行它之后,这个文本和图像组件没有更新

我将非常感激这个问题的解决

亲切问候,,
Aru

您需要花费几行代码来扩展和配置detailview。但是,您不能在任何地方使用detailview。

使用detailview是什么意思?隐马尔可夫模型。。我想我用它从detailview中找到ImageView和TextView。请查看以下来源:ImageView detailimg=ImageView detailview.findViewByIdR.id.img\u detail;TextView detailtxt=TextView detailview.findviewbydr.id.txt\u detail;并且detailview设置在ViewFlipper布局上,因此它必须在动画消失后显示。难道我的执行不正确吗?
protected void onListItemClick(ListView l, View v, int position, long id) {
    try {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        // TODO Auto-generated method stub
        LayoutInflater factory = getLayoutInflater();
        View detailview = factory.inflate(R.layout.top_detail,null);

        ImageView detailimg = (ImageView) detailview.findViewById(R.id.img_detail);
        TextView detailtxt = (TextView) detailview.findViewById(R.id.txt_detail);

        if (position == SUKIMA) {
            detailimg.setImageResource(R.drawable.sukima);
            detailtxt.setText(R.string.sukima_detail);
        } else if (position == TAJUUJIN) {
            detailimg.setImageResource(R.drawable.pu_tajuujin);
            detailtxt.setText(R.string.tajuujin_detail);
        } else if (position == LOVERS) {
            detailimg.setImageResource(R.drawable.pu_lovers);
            detailtxt.setText(R.string.lovers_detail);
        }

        this.flipper.setInAnimation(AnimationSanmon.inFromRightAnimation());
        this.flipper.setOutAnimation(AnimationSanmon.outToLeftAnimation());
        this.flipper.showNext();

        detailimg.setImageDrawable(detailview.getResources().getDrawable(R.drawable.sukima));
        detailtxt.setText(R.string.sukima_detail);

    } catch (Exception e) {
        e.printStackTrace();
    }
}