도움이 필요합니다. 앱을 개발 중입니다.onItemClick FirstFragment로 이동하는 경우 elseFragment로 이동
내 탐색 모음입니다. 세 가지 옵션 메뉴 (색깔있는 메뉴)가 있습니다.
1) 세 번째 조각을)
2) 3
을 MapFragment가
클릭하면 설치 목록으로 구성된 다른 조각 (ListFragment)이 열립니다. 기능은 FirstFragment에 그렇지 않으면 MapFragment가 이동에
사업체는 것이다.
시나리오 : 사용자가 은행에가 있는지 확인합니다를 클릭 할 때
1) 내가 에있어 경우 FirstFragment-> 탐색을 클릭 drawer->이 시나리오> 은행
을 ListFragment-을 클릭 사용자가 FirstFragment에 있으면 FirstFragment로 진행합니다. 그렇지 않으면 MapFragment ........로 이동합니다. 결과는 FirstFragment로 이동합니다.
2) 내가 MapFragment-에있어 경우> drawer-> 사용자가 그렇지는 MapFragment가로 이동합니다 FirstFragment에있는 경우 그것은 확인> 은행
을 ListFragment-을 클릭 탐색을 클릭합니다 ..... ...... 결과는 MapFragment로 이동합니다.
문제 : 그래서 난 내 코드에 그것을 구현하는 방법을 모른다되어이 문제 ... 내 MainActivity에서 여기
코드 :
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
android.app.FragmentManager fragmentManager = getFragmentManager();
if (id == R.id.action_ar) {
fragmentManager.beginTransaction()
.replace(R.id.content_frame, new FirstFragment())
.commit();
Toast.makeText(this, "First Selected", Toast.LENGTH_SHORT).show();
}
else if (id == R.id.action_map) {
fragmentManager.beginTransaction()
.replace(R.id.content_frame, new MapFragment())
.commit();
Toast.makeText(this, "MAP Selected", Toast.LENGTH_SHORT).show();
}
else if (id == R.id.action_direction) {
fragmentManager.beginTransaction()
.replace(R.id.content_frame, new ThirdFragment())
.commit();
Toast.makeText(this, "Third Selected", Toast.LENGTH_SHORT).show();
}
return super.onOptionsItemSelected(item);
}
귀하의 문제는'FirstFragment'에 존재하는, 당신이 그 코드를 표시해야하므로이 예제 코드를 사용 할 일에 대한 ... –
문제는 어떻게해야할지 모르겠다. 그래서 제가 도움이 필요합니다. – Problematic
더 많은 코드로 질문을 편집 해주십시오. 질문이 명확하지 않은 것 같습니다. –