I know this question is asked already but they didn't work for me(lots of them were for earlier versions of android studio that I couldn't find the menus in 0.8.2.
the R is marked red.and I don't know what should i do with this. MainListActivity.java :
import android.app.ListActivity;
import android.content.res.Resources;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.Toast;
public class MainListActivity extends ListActivity {
protected String[] mAndroidNames;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blog_reader);
Resources resources = getResources();
mAndroidNames = resources.getStringArray(R.array.android_names);
// ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,mAndroidNames);
// setListAdapter(adapter);
Toast.makeText(this,R.string.No_items,Toast.LENGTH_LONG).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.blog_reader, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
AndroidMainfest.xml:
A<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.habib.blogreader" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainListActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">BlogReader</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="No_items">No items to display</string>
<String-array name = "android_names">
<items>Android 1</items>
<items>Android 2</items>
<items>Android 3</items>
<items>Android 4</items>
<items>Android 5</items>
<items>Android 6</items>
<items>Android 7</items>
<items>Android 8</items>
<items>Android 9</items>
<items>Android 10</items>
<items>Android 11</items>
</String-array>
</resources>
the other questions are for earlier versions of android studio I have 0.8.2 , for example there was an
answer :enable external build but there isn't in the 0.8.2(in that address).
And most of them are for eclipse not for android studio.