2
我需要在用戶單擊一個在FrameLayout中呈現的按鈕後開始一個新活動。它呈現我想要用戶點擊的按鈕,但當然它現在沒有做任何事情。在FrameLayout中開始活動
該類的代碼如下,但我不能調用startActivity(intent)。
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);
}
}
非常感謝!
非常感謝您的幫助! – noloman 2012-04-11 14:52:41