MainActivity.java:カスタムレイアウトからxmlレイアウトを作成します。出来ますか?
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setTitle(R.string.app_name);
setContentView(new SampleView(this));
}
}
SampleView.java:
public class SampleView extends View {
@Override
protected void onDraw(Canvas canvas) {
if (certaincondition = true) {
//add elements to canvas etc
} else {
//How do I do the below? The layout is defined in xml.
//I do not want to use Intent. Please help me
//create a layout from resource R.layout.idAbout and transfer control.
}
}
}
実際の問題はここに記述されています。http://stackoverflow.com/questions/4926478/why-does-the-menu-button-in-the-emulator-show-all-the-activities-of-my-app 。私はそれを修正することができませんでした:回避策として、私はすべての私の意見に同じ活動を使用しようとしています。 – hsbgowd
同じアクティビティで複数のビューを使用する元の問題が解決されました。ありがとうございました。 – hsbgowd