Android 正在FrameLayout中启动活动
我需要在用户单击在FrameLayout中呈现的按钮后启动一个新活动。它呈现了我希望用户单击的按钮,但是现在它当然什么都没有做 该类的代码如下所示,但我不能调用startActivityintentAndroid 正在FrameLayout中启动活动,android,android-intent,android-activity,android-framelayout,Android,Android Intent,Android Activity,Android Framelayout,我需要在用户单击在FrameLayout中呈现的按钮后启动一个新活动。它呈现了我希望用户单击的按钮,但是现在它当然什么都没有做 该类的代码如下所示,但我不能调用startActivityintent public class TopBarView extends FrameLayout { private ImageView mLogoImage; private Button mInfoButton; public TopBarView(Context contex
public class TopBarView extends FrameLayout {
private ImageView mLogoImage;
private Button mInfoButton;
public TopBarView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public TopBarView(Context context) {
super(context);
init();
}
public TopBarView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.top_bar, null);
mLogoImage = (ImageView) view.findViewById(R.id.imageLogo);
mInfoButton = (Button) view.findViewById(R.id.infoButton);
mInfoButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// We load & render the view for the information screen
// Intent i = new Intent();
// i.setClass(getContext(), MeerActivity.class);
// startActivity(i);
}
});
addView(view);
}
}
提前多谢 变化:
public void onClick(View v) {
// We load & render the view for the information screen
// Intent i = new Intent();
// i.setClass(getContext(), MeerActivity.class);
// startActivity(i);
}
致:
注意:最好通过您正在使用的活动分配onclicklistener,以便在您想要使用MeePractivity以外的其他对象作为目标时,TopBarView更易于重用。没有大的变化:
public void onClick(View v) {
// We load & render the view for the information screen
// Intent i = new Intent();
// i.setClass(getContext(), MeerActivity.class);
// startActivity(i);
}
致:
注意:最好通过您正在使用的活动分配onclicklistener,以便在您想要使用MeePractivity以外的其他对象作为目标时,TopBarView更易于重用。没什么大不了的