2017-09-26 25 views
0

ボタンをクリックしたときに編集ビューにテキストが表示されるように単純なアンドロイドプロジェクトを作成するだけです。デバイスがロックされていないときにアプリが表示されない

問題を私は、アプリケーションを実行すると、私は使用可能な仮想デバイスを選択し、 "OK"、エミュレータが起動すると、デバイスのロックを解除するが、アプリケーションが表示されません。なぜなのかご存知ですか?

コードはここにある:

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     TextView tview = (TextView) findViewById(R.id.textView); 
     EditText input_text = (EditText) findViewById(R.id.editText); 
     String message = input_text.getText().toString(); 
     tview.setText(message); 
    } 

はcontent_main.xml:あなたがこれを追跡するために行うことができます

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 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" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.example.ricardorei.myapplication.MainActivity" 
    tools:showIn="@layout/activity_main"> 

     <Button 
      android:id="@+id/button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button" 
      android:layout_marginBottom="8dp" 
      app:layout_constraintBottom_toBottomOf="parent" 
      app:layout_constraintTop_toTopOf="parent" 
      android:layout_marginTop="8dp" 
      app:layout_constraintVertical_bias="0.4000002" 
      android:layout_marginRight="8dp" 
      app:layout_constraintRight_toRightOf="parent" /> 

     <EditText 
      android:id="@+id/editText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:inputType="textPersonName" 
      android:text="Name" 
      /> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="TextView" 
      android:layout_marginBottom="8dp" 


      /> 

    </android.support.constraint.ConstraintLayout> 
+0

エミュレータが少し遅くなる可能性があります。Androidスタジオを確認してください。エミュレータにまだ展開されている可能性がありますが、通常は遅くなります。 –

+0

Runタブを見て(logcatの一番下にある)、そこにエラーが表示されている可能性があります。 – crgarridos

+0

ありがとう、ちょうどエラーなしでアプリを起動して表示されます。 – JonD

答えて

0

もの:

のGradleが正常にアプリを構築するかどうかを1-チェック。

2 - ツールバーに表示されている停止ボタンを追跡します。

3チェックでエラーが記録される可能性があります。

関連する問題