setContentView(R.layout.activity_main);
listView=(MsgListView)findViewById(R.id.matterListtView);
payProductFragment=(PayProductFragment)this.getSupportFragmentManager().findFragmentById(R.id.payProductFragment);
this.getSupportFragmentManager().beginTransaction().hide(payProductFragment).commit();
listView.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0,View arg1,int index,long arg3)
{
Log.d("TAG","开始处理listView点击事件!!!!!~~~~~");
Product p=listAdapter.getItem(index-1);
payProductFragment.setData(p);
MainActivity.this.getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right).show(payProductFragment).commit();
}
});
在setContentView方法中载入了activity_mail.xml布局文件,布局文件中只包含一个MsgListView(ListView的继承类),和一个PayProductFragment(Fragment的继承类),这个Fragment是一个详细信息的展示页面,我先让Fragment隐藏,在点击ListView的某个项时,再将该Fragment显示出来。
上面代码基本是参照一个范例写的,但不知道为什么,点击ListView的项后,没有任何反应,Log显示开始处理ListView的点击事件,但fragment页面不会显示出来,哪位大侠能指导一下为什么?
listView=(MsgListView)findViewById(R.id.matterListtView);
payProductFragment=(PayProductFragment)this.getSupportFragmentManager().findFragmentById(R.id.payProductFragment);
this.getSupportFragmentManager().beginTransaction().hide(payProductFragment).commit();
listView.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0,View arg1,int index,long arg3)
{
Log.d("TAG","开始处理listView点击事件!!!!!~~~~~");
Product p=listAdapter.getItem(index-1);
payProductFragment.setData(p);
MainActivity.this.getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right).show(payProductFragment).commit();
}
});
在setContentView方法中载入了activity_mail.xml布局文件,布局文件中只包含一个MsgListView(ListView的继承类),和一个PayProductFragment(Fragment的继承类),这个Fragment是一个详细信息的展示页面,我先让Fragment隐藏,在点击ListView的某个项时,再将该Fragment显示出来。
上面代码基本是参照一个范例写的,但不知道为什么,点击ListView的项后,没有任何反应,Log显示开始处理ListView的点击事件,但fragment页面不会显示出来,哪位大侠能指导一下为什么?