I try to set share item using Navigation Drawer Activity in android studio,
<menu>
<item
android:id="@+id/navShare"
android:icon="@drawable/ic_menu_share"
android:title="Share" />
this is the xml
code for that.
problem was come when I try to write java code for this propose,
problem is what is the typecast type of this navShare
menu item in this java code.
} else if (id == R.id.navShare) {
share = () findViewById (R.id.navShare);
share.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent shareIntent = new Intent (Intent.ACTION_SEND);
shareIntent.setType("text/plain");
String shareBody = "your body here";
String shareSub = "Your subject here";
shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSub);
shareIntent.putExtra (Intent.EXTRA_TEXT, shareBody);
startActivity (Intent.createChooser (shareIntent,"Share App Locker"));