2016-12-07 4 views
-1

私のアプリケーションを実行すると、何も起こりませんが、ボタンがクリックされても何も起こりません。ここ はスクリーンショット私はここに私のJavaコードが間違っているのだろうかと思っていた。ボタンは新しいウィンドウを開くためのものですが、それはありません

package xyz.gregswebsite.notes; 

import android.content.Intent; 
import android.os.Bundle; 
import android.support.design.widget.FloatingActionButton; 
import android.support.design.widget.Snackbar; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.view.View; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View.OnClickListener; 
import android.widget.Button; 

public class note_taker extends AppCompatActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.content_main); 

    Button advanceToTaker = (Button) findViewById(R.id.button); 
    advanceToTaker.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      Intent intent = new Intent(note_taker.this, anther_class.class); 
      startActivity(intent); 
     } 
    }); 

} 

}

、ここで一緒に私のJavaやXMLである私のxmlはここ

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:id="@+id/content_main" 
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" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="xyz.gregswebsite.notes.MainActivity" 
tools:showIn="@layout/activity_main"> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="You have no notes" 
    android:textSize="20dp" 
    android:id="@+id/textView" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" /> 

<Button 
    android:text="Button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_toStartOf="@+id/textView" 
    android:id="@+id/button" /> 


</RelativeLayout> 

でのスクリーンショットです: ! http://imgur.com/gallery/Hqe7Uhttp://imgur.com/gallery/rCphx

<?xml version="1.0" encoding="utf-8"?> 

<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" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

</manifest> 
+0

anther_classコードも投稿できますか? – Raghavendra

+0

あなたは正しいコンテンツを設定しましたか? 'setContentView(R.layout.content_main);'木のボタンはそれで何も... – Opiatefuchs

+0

@Raghavendraそのわずかテストクラスがどこにある同じでなければならない、新しいウィンドウを配置すべき場所ということでしょうか? –

答えて

0
<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" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
<activity 
     android:name=".anther_class"/> 
<activity 
     android:name=".note_taker"/> 
</application> 
+0

それは役に立たなかった、私は同じ結果を得る。 –

+0

クラッシュしましたか? –

+0

いいえ、ボタンをタップすると何も起こりません。 –

1

あなたはnote_takerアクティビティを使用していると私はあなたのXMLでは、

tools:context="xyz.gregswebsite.notes.MainActivity" 
tools:showIn="@layout/activity_main" 

なぜこの投稿をすることを見つけることができますか?

は、右のアクティビティコンテキストを使用してXMLを修正して、実行してみてください。

+0

で//imgur.com/a/RmXvO – AxelH

関連する問題