add DisplayMessageActivity - still using main layout
This commit is contained in:
parent
0998a4905f
commit
3b66232af4
@ -11,5 +11,12 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".DisplayMessageActivity"
|
||||||
|
android:label="@string/title_activity_display_message">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value="com.example.myfirstapp.MainActivity" />
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/button_send" />
|
android:text="@string/button_send"
|
||||||
|
android:onClick="sendMessage" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -3,4 +3,5 @@
|
|||||||
<string name="app_name">Joshs First App</string>
|
<string name="app_name">Joshs First App</string>
|
||||||
<string name="edit_message">Enter your message, fu</string>
|
<string name="edit_message">Enter your message, fu</string>
|
||||||
<string name="button_send">Send It, Yo</string>
|
<string name="button_send">Send It, Yo</string>
|
||||||
|
<string name="title_activity_display_message">Da Message</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
14
src/com/example/myfirstapp/DisplayMessageActivity.java
Normal file
14
src/com/example/myfirstapp/DisplayMessageActivity.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.example.myfirstapp;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class DisplayMessageActivity extends Activity
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.main);
|
||||||
|
}
|
||||||
|
}
|
@ -2,9 +2,14 @@ package com.example.myfirstapp;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
public class MainActivity extends Activity
|
public class MainActivity extends Activity
|
||||||
{
|
{
|
||||||
|
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
@ -12,4 +17,13 @@ public class MainActivity extends Activity
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user