Android 앱을 개발하고 작업 표시 줄에 두 개의 메뉴가 있습니다. 각 작업에 대해 작업을 수행하지만 그 중 하나만 액세스 할 수 있습니다.이 코드는 내 코드작업 바에 다른 작업 수행
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
Toast.makeText(this, "Studentsite News", Toast.LENGTH_LONG).show();
Intent i = new Intent(this, ssnews.class);
startActivity(i);
return true;
}
public boolean onOptionsItemSelected1(MenuItem item)
{
Toast.makeText(this, "About", Toast.LENGTH_LONG).show();
Intent i = new Intent(this, about.class);
startActivity(i);
return true;
}
문제를 해결 하시겠습니까? 나는 정말로 감사 할 것입니다.
왜이'onOptionsItemSelected'? 어떤 메뉴가 선택되었는지 확인하고 해당 활동을 시작하기 위해'switch case '를 사용하십시오. –
은 작동하는 첫 번째 메뉴이며 두 번째는 작동하지 않습니까? –
onOptionsItemSelected 내에서 스위치를 사용하십시오. 코드를 업데이트하십시오. –