Guest User

Untitled

a guest
Feb 2nd, 2016
165
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="vertical"
  7. android:background="#b7da41">
  8.  
  9. <TextView
  10. android:text="Name"
  11. android:layout_height="wrap_content"
  12. android:layout_width="fill_parent"/>
  13.  
  14. <EditText
  15. android:id="@+id/name"
  16. android:layout_height="wrap_content"
  17. android:layout_width="fill_parent"/>
  18. <TextView
  19. android:text="business"
  20. android:layout_height="wrap_content"
  21. android:layout_width="fill_parent"/>
  22.  
  23. <EditText
  24. android:id="@+id/business"
  25. android:layout_height="wrap_content"
  26. android:layout_width="fill_parent"/>
  27. <TextView
  28. android:text="Adress"
  29. android:layout_height="wrap_content"
  30. android:layout_width="fill_parent"/>
  31.  
  32. <EditText
  33. android:id="@+id/Adress"
  34. android:layout_height="wrap_content"
  35. android:layout_width="fill_parent"/>
  36. <TextView
  37. android:text="star"
  38. android:layout_height="wrap_content"
  39. android:layout_width="fill_parent"/>
  40.  
  41. <EditText
  42. android:id="@+id/srat"
  43. android:layout_height="wrap_content"
  44. android:layout_width="fill_parent"/>
  45. <TextView
  46. android:text="where"
  47. android:layout_height="wrap_content"
  48. android:layout_width="fill_parent"/>
  49. <EditText
  50. android:id="@+id/where"
  51. android:layout_height="wrap_content"
  52. android:layout_width="fill_parent"/>
  53. <TextView
  54. android:text="Phone Number"
  55. android:layout_height="wrap_content"
  56. android:layout_width="fill_parent"/>
  57. <EditText
  58. android:id="@+id/Phonenumber"
  59. android:layout_height="wrap_content"
  60. android:layout_width="fill_parent"/>
  61. <Button
  62. android:id="@+id/button"
  63. android:text="Save"
  64. android:layout_height="wrap_content"
  65. android:layout_width="fill_parent"
  66. />
  67.  
  68. </LinearLayout>
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. package com.example.mbakungoma001.myapplication;
  79.  
  80. import android.content.Intent;
  81. import android.support.v7.app.AppCompatActivity;
  82. import android.os.Bundle;
  83. import android.view.View;
  84. import android.widget.Button;
  85. import android.widget.EditText;
  86.  
  87. public class MainActivity extends AppCompatActivity {
  88.  
  89. @Override
  90. protected void onCreate(Bundle savedInstanceState) {
  91. super.onCreate(savedInstanceState);
  92. setContentView(R.layout.activity_main);
  93. Button button=(Button)findViewById(R.id.button);
  94.  
  95. final EditText editTextName=(EditText)findViewById(R.id.name);
  96. final EditText editTExtBusiness=(EditText)findViewById(R.id.business);
  97. final EditText editTExtAdress=(EditText)findViewById(R.id.Adress);
  98. final EditText editTExtStart=(EditText)findViewById(R.id.srat);
  99. final EditText editTExtWhere=(EditText)findViewById(R.id.where);
  100. final EditText editTExtPhonenumber=(EditText)findViewById(R.id.Phonenumber);
  101.  
  102. // add button onClick Listener
  103. button.setOnClickListener(new View.OnClickListener()
  104. {public void onClick(View v) {
  105.  
  106. // TODO Auto-generated method stub
  107.  
  108.  
  109. String name = editTextName.getText().toString();
  110. String business = editTExtBusiness.getText().toString();
  111. String adress = editTExtAdress.getText().toString();
  112. String starter = editTExtStart.getText().toString();
  113. String whereAdress = editTExtWhere.getText().toString();
  114. String phone = editTExtPhonenumber.getText().toString();
  115.  
  116. // create a new intent
  117. Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
  118. // put the data to be sent to the next activity
  119.  
  120.  
  121. Bundle bundle = new Bundle();
  122. intent.putExtra("BundleData",bundle);
  123.  
  124. bundle.putString("stringOne",name);
  125. bundle.putString("stringTwo", business );
  126. bundle.putString("stringThree",adress);
  127. bundle.putString("stringFour", starter);
  128. bundle.putString("stringFive",whereAdress);
  129. bundle.putString("stringSix",phone);
  130.  
  131.  
  132.  
  133.  
  134. startActivity(intent);
  135.  
  136.  
  137. }
  138. });
  139. }
  140.  
  141. }
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148. package com.example.mbakungoma001.myapplication;
  149.  
  150. import android.content.Intent;
  151. import android.support.v7.app.AppCompatActivity;
  152. import android.os.Bundle;
  153. import android.widget.ArrayAdapter;
  154. import android.widget.ListView;
  155.  
  156. import java.util.ArrayList;
  157. import java.util.Arrays;
  158.  
  159. public class Main2Activity extends AppCompatActivity {
  160.  
  161. @Override
  162. protected void onCreate(Bundle savedInstanceState) {
  163. super.onCreate(savedInstanceState);
  164. setContentView(R.layout.activity_main2);
  165.  
  166. // setContentView(Your_Layout);
  167. //Bundle extras = null;
  168. //if(getIntent().getExtras() != null){
  169. // extras = getIntent().getExtras();
  170. //}
  171.  
  172.  
  173. Intent intent = getIntent();
  174. // ListView lv = (ListView) findViewById(R.id.View);
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. String first = intent.getStringExtra("stringOne");
  183. String second = intent.getStringExtra("stringTwo");
  184. String Third = intent.getStringExtra("stringThree");
  185. String Fourth = intent.getStringExtra("stringFour");
  186. String Fifth = intent.getStringExtra("stringFive");
  187. String Sixth = intent.getStringExtra("stringSix");
  188.  
  189. // Find the ListView resource.
  190. ListView lv = (ListView) findViewById( R.id.View );
  191.  
  192. // Create and populate a List of planet names.
  193. String[] dataUser = new String[] { first,second,Third,Fourth,Fifth,Sixth};
  194. ArrayList<String> dataList = new ArrayList<String>();
  195. dataList.addAll(Arrays.asList(dataUser));
  196.  
  197. // Create ArrayAdapter using the planet list.
  198. ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dataList);
  199.  
  200.  
  201.  
  202. // Set the ArrayAdapter as the ListView's adapter.
  203. lv.setAdapter(listAdapter);
  204. }
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211. }
RAW Paste Data