java - Android.com's basic app won't show DisplayMessageActivity in app -


so i'm building basic app tutorial, can't displayactivitymessage class work in app itself. no errors, nothing, nothing happens when input text , press button "send".

heres classes , xmls.

mainactivity.java

package com.example.nan.joro2;  import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.content.intent; import android.view.view; import android.widget.edittext; import android.widget.textview;     public class mainactivity extends actionbaractivity {     public final static string extra_message = "com.example.nan.joro2.message";      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     }     //virker når brugeren trykker på knappen     public void sendmessage(view view){         intent intent = new intent(this, displaymessageactivity.class);         edittext edittext = (edittext) findviewbyid(r.id.edit_message);         string message = edittext.gettext().tostring();         intent.putextra(extra_message, message);     } } 

displaymessageactivity.java

package com.example.nan.joro2;  import android.content.intent; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.widget.textview;   public class displaymessageactivity extends actionbaractivity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          intent intent = getintent();         string message = intent.getstringextra(mainactivity.extra_message);          textview textview = new textview(this);         textview.settextsize(40);          textview.settext(message);         setcontentview(textview);       }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     } } 

androidmanifest.xml

    <?xml version="1.0" encoding="utf-8"?>     <manifest xmlns:android="http://schemas.android.com/apk/res/android"         package="com.example.nan.joro2" >          <application             android:allowbackup="true"             android:icon="@mipmap/ic_launcher"             android:label="@string/app_name"             android:theme="@style/apptheme" >             <activity                 android:name=".mainactivity"                 android:label="@string/app_name" >                 <intent-filter>                     <action android:name="android.intent.action.main" />                      <category android:name="android.intent.category.launcher" />                 </intent-filter>             </activity>             <activity                 android:name=".displaymessageactivity"                 android:label="@string/title_activity_display_message"                 android:parentactivityname=".mainactivity" >                 <meta-data                     android:name="android.support.parent_activity"                     android:value="com.example.nan.joro2.mainactivity" />             </activity>         </application>      </manifest> 

strings.xml

<resources>     <string name="app_name">joro2</string>     <string name="edit_message">enter message</string>     <string name="button_send">send</string>     <string name="action_settings">settings</string>     <string name="title_activity_main">mainactivity</string>     <string name="title_activity_display_message">my message</string>      <string name="hello_world">hello world!</string> </resources> 

activity_main.xml

<linearlayout 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"      >      <edittext android:id="@+id/edit_message"         android:layout_width="0dp"         android:layout_weight="1"         android:layout_height="wrap_content"         android:hint="@string/edit_message" />     <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="@string/button_send"         android:onclick="sendmessage"/>  </linearlayout> 

add startactivity(intent); in sendmessage() method


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -