Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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"
- android:orientation="vertical"
- android:background="#b7da41">
- <TextView
- android:text="Name"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <EditText
- android:id="@+id/name"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <TextView
- android:text="business"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <EditText
- android:id="@+id/business"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <TextView
- android:text="Adress"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <EditText
- android:id="@+id/Adress"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <TextView
- android:text="star"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <EditText
- android:id="@+id/srat"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <TextView
- android:text="where"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <EditText
- android:id="@+id/where"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <TextView
- android:text="Phone Number"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <EditText
- android:id="@+id/Phonenumber"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"/>
- <Button
- android:id="@+id/button"
- android:text="Save"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- />
- </LinearLayout>
- package com.example.mbakungoma001.myapplication;
- import android.content.Intent;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Button button=(Button)findViewById(R.id.button);
- final EditText editTextName=(EditText)findViewById(R.id.name);
- final EditText editTExtBusiness=(EditText)findViewById(R.id.business);
- final EditText editTExtAdress=(EditText)findViewById(R.id.Adress);
- final EditText editTExtStart=(EditText)findViewById(R.id.srat);
- final EditText editTExtWhere=(EditText)findViewById(R.id.where);
- final EditText editTExtPhonenumber=(EditText)findViewById(R.id.Phonenumber);
- // add button onClick Listener
- button.setOnClickListener(new View.OnClickListener()
- {public void onClick(View v) {
- // TODO Auto-generated method stub
- String name = editTextName.getText().toString();
- String business = editTExtBusiness.getText().toString();
- String adress = editTExtAdress.getText().toString();
- String starter = editTExtStart.getText().toString();
- String whereAdress = editTExtWhere.getText().toString();
- String phone = editTExtPhonenumber.getText().toString();
- // create a new intent
- Intent intent = new Intent(getApplicationContext(), Main2Activity.class);
- // put the data to be sent to the next activity
- Bundle bundle = new Bundle();
- intent.putExtra("BundleData",bundle);
- bundle.putString("stringOne",name);
- bundle.putString("stringTwo", business );
- bundle.putString("stringThree",adress);
- bundle.putString("stringFour", starter);
- bundle.putString("stringFive",whereAdress);
- bundle.putString("stringSix",phone);
- startActivity(intent);
- }
- });
- }
- }
- package com.example.mbakungoma001.myapplication;
- import android.content.Intent;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- import java.util.ArrayList;
- import java.util.Arrays;
- public class Main2Activity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main2);
- // setContentView(Your_Layout);
- //Bundle extras = null;
- //if(getIntent().getExtras() != null){
- // extras = getIntent().getExtras();
- //}
- Intent intent = getIntent();
- // ListView lv = (ListView) findViewById(R.id.View);
- String first = intent.getStringExtra("stringOne");
- String second = intent.getStringExtra("stringTwo");
- String Third = intent.getStringExtra("stringThree");
- String Fourth = intent.getStringExtra("stringFour");
- String Fifth = intent.getStringExtra("stringFive");
- String Sixth = intent.getStringExtra("stringSix");
- // Find the ListView resource.
- ListView lv = (ListView) findViewById( R.id.View );
- // Create and populate a List of planet names.
- String[] dataUser = new String[] { first,second,Third,Fourth,Fifth,Sixth};
- ArrayList<String> dataList = new ArrayList<String>();
- dataList.addAll(Arrays.asList(dataUser));
- // Create ArrayAdapter using the planet list.
- ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dataList);
- // Set the ArrayAdapter as the ListView's adapter.
- lv.setAdapter(listAdapter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement