Я новичок в программировании. Я только изучил основы. Прямо сейчас, я пытаюсь разработать Android с Android Studio. У моей программы просто есть заголовок и две кнопки, которые должны открыть URL. В моем коде не похоже ничего плохого, потому что ничего не подчеркнуто красным цветом, поэтому я не понимаю, почему модель макета не отображается в эмуляторе.Android-эмулятор Studio открывается, но черный экран
Что-то, что влияет на правильность запуска эмулятора? Я попробовал это на компьютере с Windows, и эмулятор пришел через минуту или около того. Но ничего для Mac. В любом случае, чтобы ускорить процесс?
В моем коде не было ошибок. Единственная проблема, с которой я сталкиваюсь, - это эмулятор, который не работает своевременно. Предполагается, что приложение должно открыть URL-адрес для каждой из двух кнопок в браузере.
Запуск на Macbook Pro Mid 2010 13" с 8 Гб оперативной памяти
***************************** ********* Код деятельности *************************************** *******
package com.first.bharg.firstapp;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonOnClick();
}
public void buttonOnClick(){
Button b = (Button) findViewById(R.id.button);
Button b1 = (Button) findViewById(R.id.button2);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i1 =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.yahoo.com"));
startActivity(i1);
}
});
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i2 =
new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(i2);
}
});
}
@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_main, 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);
}
}
************************************ ************ Layout ************************************* *****
<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=".MainActivity"
android:id="@+id/activity_main"
android:clickable="true"
android:background="#ffffa157"
android:focusable="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yahoo"
android:id="@+id/button"
android:layout_marginTop="107dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="51dp"
android:layout_marginStart="51dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Google"
android:id="@+id/button2"
android:layout_alignBottom="@+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="42dp"
android:layout_marginEnd="42dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="First App"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Пожалуйста, покажите свой код активности и файл макета. – stkent
Попробуйте https://www.genymotion.com/#!/ – Mieszko
Используете ли вы ускоренный x86 AVD или более медленный ARM? –