Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
7e5ceeac53 | |||
3b66232af4 | |||
0998a4905f | |||
e82cfeacd5 |
@ -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>
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
>
|
>
|
||||||
<TextView
|
<EditText android:id="@+id/edit_message"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Hello World, MainActivity"
|
android:layout_weight="1"
|
||||||
/>
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">MainActivity</string>
|
<string name="app_name">Joshs First App</string>
|
||||||
|
<string name="edit_message">Enter your message, fu</string>
|
||||||
|
<string name="button_send">Send It, Yo</string>
|
||||||
|
<string name="title_activity_display_message">Da Message</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
21
src/com/example/myfirstapp/DisplayMessageActivity.java
Normal file
21
src/com/example/myfirstapp/DisplayMessageActivity.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package com.example.myfirstapp;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
public class DisplayMessageActivity extends Activity
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public 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);
|
||||||
|
}
|
||||||
|
}
|
@ -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