メニューと呼ばれるビューを作成しました。私はそれをシングルトンにしました。これはそれのコンストラクタです:他のアクティビティーでもう一度表示されないビュー
private Menu(Activity cx) {
super(cx);
this.context = cx;
// something = AsyncTaskGetAllStreams.numberOfStreams;
LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
li.inflate(R.layout.menu, this, true);
setActivity(cx);
initUI();
initUI(MyStreamsActivity.streamsJoinedByUser2.length);
assignVal();
}
私が午前の問題は、このレイアウトの活動が設定されると、それはその活動に示し、他にそれはLogCatに私にこのことを伝えることです:については
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
あなたの参照は私のボタンのonClick()
から始まります。これは私がonClick()
Intent intent = new Intent(activity, MyPostActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(intent);
に処理するコードですが、なぜでしょう?ありますか何をすべきか?
私はそれを使用する場合は、http://stackoverflow.com/questions/6371277/help-to-resolve-exception-the-specified-child-already-has-a-parent-you-must-ca – Vivek