I am trying to develop a simple weather forecast app. Android Studio v2.2 Minimum SDK set to API10:Gingerbread.
Problem - I need a Search City option on my 1st page.So I simply edited the menu_main.xml file and added that option. My problem is that the Search City option appears in 'design' and 'preview' section of menu_main.xml but does not appear when I check the 'design'or 'preview' section of my activity_main.xml .
I have set theme to @style/AppTheme in manifests also.
In that red highlighted part I want my menu to appear..
My menu file is-
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity" >
<item
android:id="@+id/change_city"
android:orderInCategory="100"
android:title="@string/change_city"
app:showAsAction="always"/>
</menu>
My mainactivity.xml is-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#ff1ba1ee"``
tools:context="com.example.hp.theweatherapp.MainActivity">
I have not added whole xml as it just contains simple TextViews.
My MainActivity.java is-
package com.example.hp.theweatherapp;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Manifests.xml is-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hp.theweatherapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
any help is appreciated..thanks..