Q:

android activity not showing in only main activity and not showing properly

action bar not showing in main activity while the same code present for another activity and another thing action bar overflow not showing by list in right corner

image 1 : main activity with menu key pressed

image 2 : show message activity

code for main activity:
public class MainActivity extends ActionBarActivity {
EditText t;
public final static String sendMessageextra="com.example.example2.textmessage";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    t=(EditText) findViewById(R.id.textmessage);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.activity_main_actions, menu);
    return super.onCreateOptionsMenu(menu);
}

public void sendMessage(View v){
    Intent sendmessageintent=new Intent(this,showMessage.class);
    String messagestring=t.getText().toString();
    sendmessageintent.putExtra(sendMessageextra, messagestring);
    startActivity(sendmessageintent);
}

}
show message activity:
public class showMessage extends Activity{
TextView t;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sendmessage);
    t=(TextView) findViewById(R.id.showmessage);
    showmessage();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater inflater=getMenuInflater();
    inflater.inflate(R.menu.activity_main_actions, menu);
    return true;
}

public void showmessage(){
    Intent intent=getIntent();
    String message=intent.getStringExtra(MainActivity.sendMessageextra);
    t.setText(message);
    Log.i("Set New Text Box", "Text BOx");
}

}
activity main actions.xml:
<? xml version="1.0" encoding="utf-8"? >
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!--  Search Widget -->
<item android:id="@+id/action_search"
      android:icon="@drawable/ic_action_search"
      android:title="@string/action_search"
      android:showAsAction="ifRoom"
      android:actionViewClass="android.widget. SearchView"/>

<!--  Location Found -->
<item android:id="@+id/action_location_found"
      android:icon="@drawable/ic_action_location_found"
      android:title="@string/action_location_found"
      android:showAsAction="never" />
<!--  Help -->
<item android:id="@+id/action_help"
      android:icon="@drawable/ic_action_help"
      android:title="@string/action_help" 
      android:showAsAction="never"/>
</menu>

android menifest file:
Activity Manifest File:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.example2"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=". MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action. MAIN" />
                <category android:name="android.intent.category. LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.example2.showMessage"
            android:label="Show Message" android:parentActivityName="com.example.example2.MainActivity"/>
    </application>
</manifest>

A:

If you want to show the search icon in the right of the actionbar in every activity then just make a change in the actions.xml instead of android:showAsAction="ifRoom" change it to android:showAsAction="always"

