I am learning Android with tutorial from his page, and I have problem in part: Running Your App chapter. When I see activity_my.xml
preview I see "Hello world" text, but when I run application and see emulated device, emulator shows device with only black page and "android" text. I think I can't start it properly, but in Android Studio console I see:
C:\Users\Abc\AppData\Local\Android\sdk\tools\emulator.exe
-avd Nexus_4_cale -netspeed full -netdelay none
creating window 208 44 800 480
emulator: emulator window was out of view and was recentered
So it seems to be ok. But if I choose to edit "app" configuration, in Target Device / Emulator
I see that Prefer Adroid Virtual Device
, in my calse, called "Nexus_4_cale", is red. But if I edit this device there is no errors etc.. I don't know what's happening, and I will be happy if anybody would like to help me with this problem - thank you in advance.
That is how it looks in emulator:
And that is how it looks in Android Studio preview:
And that is configuration, with red device but with no explanation:
Code for activity_my.xml
:
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MyActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
And code for MyActivity.java
class:
package com.example.abc.android3;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MyActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_my, 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();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
All code is generated by Android Studio