[英]Java class extends from multiple classes
嘗試在Android開發中擴展多個類時遇到問題。 所以基本上我想做的是得到一個導航抽屜:
customAdapter = new CustomExpandAdapter(this, listParent, listDataChild);
mDrawerList.setAdapter(customAdapter);
mDrawerList.setChoiceMode(ExpandableListView.CHOICE_MODE_SINGLE);
// Navigation drawer with sub menu goes here
private void selectItem(int groupPosition, int position) {
selectedPosition = position;
mDrawerLayout.closeDrawer(navDrawerView);
// Navigation item for profile
if (groupPosition == 0) {
switch (selectedPosition) {
case 0:
break;
case 1:
break;
else if (groupPosition == 3) {
switch (selectedPosition) {
case 0:
break;
case 1:
Toast.makeText(ENeighbourhoodActivity.this, "Analyze Event",
Toast.LENGTH_LONG).show();
break;
}
}
setTitle(mEventSelection[selectedPosition]);
}
這些代碼在我的MainActivity.java中 。 然后從MainActivity中,當我選擇某些按鈕時,我將導航到Detail.java 。 但是,在我的Detail.java中 ,我正在擴展FragmentActivity,因為我在Detail.java中使用了tab:
public class EventDetailMain extends FragmentActivity {
Context context = this;
ViewPager Tab;
EventDtlTabPagerAdapter TabAdapter;
ActionBar actionBar;
}
當我進入Detail.java時,導航抽屜不再存在,因為我沒有從該類擴展。 我想知道我應該如何同時從兩個班級開始。
提前致謝。
在主要活動中,將Detail.java作為片段並編寫您的代碼。這樣,導航抽屜也可用於您的Detail.java。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.