关于“extends Fragment”问题!! [英] About "extends Fragment" Problem !!

查看:294
本文介绍了关于“extends Fragment”问题!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用标签栏分隔主屏幕(Fragment1,2,3)。在我的一个主屏幕(MainActivity)中,我尝试制作更多页面。所以我使用Inent从Fragment 1_1链接到Fragment1_2。我怀疑扩展Fragment为什么我不能在这个类上使用任何方法。



I use "tab bar" to separate main screen(Fragment1,2,3). In one of my main screen(MainActivity), I try to make more page. So I use Inent to link from Fragment 1_1 to Fragment1_2. I doubt it about extends Fragment that why I can't use any method on this class.

public class Fragment1_1 extends Fragment {
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		 return inflater.inflate(R.layout.fragment1_1, null);
	}
	

	public void btnNext(View view){
		Intent nextScreen = new Intent(getApplicationContext(),Fragment1_2.class);
		 startActivity(nextScreen);
	}
}





getApplicationContext()错误。有人知道如何OnClick像这个页面?请帮助和非常感谢。



当我使用扩展片段时,很多东西都可以运行。

推荐答案

http://developer.android.com/guide/components/fragments .html#Transactions [ ^ ]



你应该使用 FragmentTransaction



玩得开心!
http://developer.android.com/guide/components/fragments.html#Transactions[^]

You should use the FragmentTransaction.

have fun!


这篇关于关于“extends Fragment”问题!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆