[英]How to replace one fragment with another on ListView item click android
I have a fragment with simple ListView with images and text, and want to replace one fragment with another on ListView item click. 我有一个带有带有图像和文本的简单ListView的片段,并且想要在ListView项目单击时将一个片段替换为另一个片段。 How I can realize this?
我怎么能意识到这一点?
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
getSupportFragmentManager()
.beginTransaction()
.replace(getFragmentContainerId(),fragment)
.commit();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.