0
ナビゲーションレイアウトでシェアを実装することができますし、私はこのコードを使用し、共有アイテムの仕事をしたいが、それはは、どのように私は、ナビゲーションアプリを持っている
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_download) {
// Handle the camera action
} else if (id == R.id.nav_favorite) {
} else if (id == R.id.nav_allstories) {
} else if (id == R.id.nav_share) {
id.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(Intent.ACTION_SEND);
myIntent.setType("text/plain");
String shareBody="Your Body Here";
String shareSub="Your Subject Here";
myIntent.putExtra(Intent.EXTRA_SUBJECT,shareSub);
myIntent.putExtra(Intent.EXTRA_TEXT,shareBody);
startActivity(Intent.createChooser(myIntent,"Share using"));
}
});
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
を動作しません。項目。 私もShareView
を試しましたが、アンドロイドはこれをサポートしていないと思います。
'onNavigationItemSelected(MenuItem item)'アイテムをクリックすると、 –
'onNavigationItemSelected'の中で' clickListener'を削除する必要はありません。すべてのことを正しく行えばうまくいくでしょう。 – Ibrahim
スイッチ/ケース構成について知りたいことがあります。 –