取代我有以下问题: public class MainActivity extends FragmentActivity implements ActionBar.TabListener
列表视图仍然可点击,即使是通过点击片段
这是通过使用ViewPager
: 我开发使用的应用程序。因此,最初的main_activity.xml是
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="none" >
<FrameLayout
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</RelativeLayout>
和framgent_container.xml包含以下
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/items_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/adv_image"
android:layout_width="fill_parent"
android:layout_height="56dp"
android:src="@drawable/no_adv" />
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/adv_image" />
</RelativeLayout>
因此,这里的问题: 我得到的名单显示正确,并在它上面的adv_image。当我点击我的列表中的一个项目时,我可以看到它应该显示的项目。 (在滚动视图中是具有图像视图和下方描述的线性布局)。 但是 当我点击图片视图(这是不可点击)! 显示先前列表中的另一项。这让我认为Listview仍然存在(在我的文章后面?很奇怪)。即使我点击了文章图片上方的一点点,它也会触发adv_image url,该url只存在于listview中,并且不在此片段内。
用文章片段替换列表视图的代码如下。
public class ArticlesListFragment extends ListFragment {
这onCreateView膨胀以下
View rootView = inflater.inflate(R.layout.items_list, container, false);
它具有以下功能
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Fragment fragment = null;
Bundle args = new Bundle();
fragment = new Article();
args.putString("unique_id", ((ArticleItem) v.getTag()).ID);
fragment.setArguments(args);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.addToBackStack("HomePage");
ft.replace(R.id.fragment_container, fragment);
ft.commit();
}
所以任何想法?????我试图取代几个不同的东西onitemclick ..但我仍然没有运气..
在此先感谢!
你是在另一个'Fragment'的顶部添加一个'Fragment'吗?一个'Fragment'顶部的ImageView?或在ListView顶部的ImageView? – Emmanuel
我有一个FragmentList,它包含一个ListView顶部的imageView,并且一个片段替代了片段列表。这个新的片段包含一个ImageView和一个TextView下面。 –