本文介绍了遇到错误code在这里活动片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的活动课code ...我想点击的ImageButton并启动片段类,但问题是我在这行上了code误差
This is my Activity Class code... i want to click the imagebutton and launch the fragment class, but the problem is i got error on the code in this line
BluActivity f = BluActivity.newInstance(index);
getSupportFragmentManager().beginTransaction().add(R.id.detail, f).commit();
我附上图片看到什么我的关于它的问题:( ...
i attach image to see whats my problem about it :( ...
import android.widget.ImageButton;
public class MainActivity extends Activity {
public static final String INDEX = "index";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupImageButton1();
}
private void setupImageButton1(){
ImageButton imgButton = (ImageButton) findViewById(R.id.bataImg2);
imgButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = getIntent();
int index = i.getIntExtra(INDEX, 0);
BluActivity f = BluActivity.newInstance(index);
getSupportFragmentManager().beginTransaction().add(R.id.detail, f).commit();
}
});
setupImageButton1();
}
private void setupImageButton3(){
ImageButton imgButton = (ImageButton) findViewById(R.id.bataImg1);
imgButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
}
}
**这里是我的错误形象附加
这里是bluactivity类
here is the bluactivity class
推荐答案
您BluActivity类似乎并不延伸片段。
Your BluActivity class doesn't seems to extend Fragment.
变化与扩展,以分片和相关的变化
Change and extend it to Fragment and related changes
这篇关于遇到错误code在这里活动片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!