私は多くのスタックオーバーフローq/aを閲覧しましたが、私の後方ナビゲーションボタンに機能を与えることはできません。戻るナビゲーションボタンなし機能
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_crime);
TextView disp1 =(TextView) findViewById(R.id.textView2);
disp1.setText("Displaying 1 of 24");
TextView displa = (TextView) findViewById(R.id.textView);
displa.setText(" China is the source of 70% of the worlds pirated goods.,");
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_crime, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.what:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,"Hey,I saw an amazing fact from Fact-O-Mania" +"\n"+"\n"+fact[i]);
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
int id = item.getItemId();
break;
case R.id.home :
finish();
}
return true;
}
http://stackoverflow.com/questions/36884194/adding-back-button-and-override-onbackpressed/ 36884707#36884707こちらをチェックしてくださいhttp://stackoverflow.com/questions/36664266/problems-with-fragment-onbackpress/36665100#36665100 –