Advertisement
adesuryadi_

jemboot

May 21st, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.example.latihan8">
  4.  
  5. <application
  6. android:allowBackup="true"
  7. android:icon="@mipmap/ic_launcher"
  8. android:label="@string/app_name"
  9. android:roundIcon="@mipmap/ic_launcher_round"
  10. android:supportsRtl="true"
  11. android:theme="@style/AppTheme">
  12. <activity android:name=".SecondActivity"
  13. android:label="Second Activity"
  14. android:parentActivityName=".MainActivity"> // manggil panah back ci atas ujung kiri
  15.  
  16. </activity>
  17.  
  18.  
  19. <activity android:name=".MainActivity">
  20. <intent-filter>
  21. <action android:name="android.intent.action.MAIN" />
  22.  
  23. <category android:name="android.intent.category.LAUNCHER" />
  24. </intent-filter>
  25. </activity>
  26. </application>
  27.  
  28. </manifest>
  29.  
  30.  
  31. =================main
  32.  
  33. <?xml version="1.0" encoding="utf-8"?>
  34. <RelativeLayout
  35. xmlns:android="http://schemas.android.com/apk/res/android"
  36. xmlns:app="http://schemas.android.com/apk/res-auto"
  37. xmlns:tools="http://schemas.android.com/tools"
  38. android:layout_width="match_parent"
  39. android:layout_height="match_parent"
  40. tools:context=".MainActivity">
  41.  
  42. <Button
  43. android:id="@+id/KirimPesan"
  44. android:layout_width="wrap_content"
  45. android:layout_height="wrap_content"
  46. android:text="KIRIM PESAN"
  47. android:layout_alignParentBottom="true"
  48. android:layout_alignParentEnd="true"
  49. android:layout_marginEnd="10dp"
  50. android:layout_marginBottom="10dp"
  51. android:onClick="kirim"
  52. />
  53.  
  54. <EditText
  55. android:id="@+id/isipesan"
  56. android:layout_width="match_parent"
  57. android:layout_height="wrap_content"
  58. android:layout_alignParentBottom="true"
  59. android:layout_toStartOf="@+id/KirimPesan"
  60. android:layout_marginStart="10dp"
  61. android:layout_marginBottom="10dp"
  62. android:hint="Tulis Pesan"
  63. />
  64.  
  65. </RelativeLayout>
  66.  
  67.  
  68. ====second
  69.  
  70. <?xml version="1.0" encoding="utf-8"?>
  71. <RelativeLayout
  72. xmlns:android="http://schemas.android.com/apk/res/android"
  73. xmlns:app="http://schemas.android.com/apk/res-auto"
  74. xmlns:tools="http://schemas.android.com/tools"
  75. android:layout_width="match_parent"
  76. android:layout_height="match_parent"
  77. tools:context=".SecondActivity">
  78.  
  79. <TextView
  80. android:id="@+id/judul"
  81. android:layout_width="wrap_content"
  82. android:layout_height="wrap_content"
  83. android:layout_marginStart="10dp"
  84. android:layout_marginTop="10dp"
  85. android:text="Pesan Diterima"
  86. style="bold"
  87. android:textSize="18sp"
  88. android:textAppearance="@android:style/TextAppearance.Medium"/>
  89.  
  90. <TextView
  91. android:id="@+id/text_received"
  92. android:layout_width="match_parent"
  93. android:layout_height="wrap_content"
  94. android:layout_below="@+id/judul"
  95. android:layout_marginStart="10dp"
  96. android:layout_marginTop="10dp"
  97. android:layout_marginEnd="10dp"
  98. android:textAppearance="@android:style/TextAppearance.Medium"
  99. android:textSize="16dp"
  100. android:background="@android:color/holo_green_light"
  101. />
  102.  
  103. </RelativeLayout>
  104.  
  105.  
  106. ===secon java
  107.  
  108. public class SecondActivity extends AppCompatActivity {
  109.  
  110. TextView tvPesan2;
  111. String Pesan2;
  112.  
  113. @Override
  114. protected void onCreate(Bundle savedInstanceState) {
  115. super.onCreate(savedInstanceState);
  116. setContentView(R.layout.activity_second);
  117.  
  118. Intent intent = getIntent();
  119. tvPesan2 = findViewById(R.id.text_received);
  120. Pesan2 = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
  121. tvPesan2.setText(Pesan2);
  122. }
  123.  
  124.  
  125. ===main java
  126.  
  127. package com.example.latihan8;
  128.  
  129. import android.content.Intent;
  130. import android.support.v7.app.AppCompatActivity;
  131. import android.os.Bundle;
  132. import android.view.View;
  133. import android.widget.EditText;
  134.  
  135. public class MainActivity extends AppCompatActivity {
  136.  
  137. EditText edPesan;
  138. public static final String EXTRA_MESSAGE = ".latihan8.extra.Message";
  139. public static final int TEXT_REQUEST = 1;
  140.  
  141. @Override
  142. protected void onCreate(Bundle savedInstanceState) {
  143. super.onCreate(savedInstanceState);
  144. setContentView(R.layout.activity_main);
  145.  
  146. edPesan = findViewById(R.id.isipesan);
  147. }
  148.  
  149. public void kirim(View view) {
  150. Intent intent = new Intent(this, SecondActivity.class);
  151. String pesan = edPesan.getText().toString();
  152. intent.putExtra(EXTRA_MESSAGE, pesan);
  153. //startActivity(intent);
  154. startActivityForResult(intent, TEXT_REQUEST);
  155. }
  156.  
  157.  
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement