main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Edit text xml testing"
/>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:inputType="number" android:id="@+id/num">
<requestFocus></requestFocus>
</EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/apha" android:inputType="text"></EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/password" android:inputType="textPassword"></EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/phone" android:inputType="phone"></EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:inputType="textMultiLine" android:id="@+id/multi">
</EditText>
<Button android:text="press and see...?" android:id="@+id/btn" android:layout_height="wrap_content" android:layout_width="wrap_content" android:onClick="btn_check"></Button>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Edit text xml testing"
/>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:inputType="number" android:id="@+id/num">
<requestFocus></requestFocus>
</EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/apha" android:inputType="text"></EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/password" android:inputType="textPassword"></EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/phone" android:inputType="phone"></EditText>
<EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:inputType="textMultiLine" android:id="@+id/multi">
</EditText>
<Button android:text="press and see...?" android:id="@+id/btn" android:layout_height="wrap_content" android:layout_width="wrap_content" android:onClick="btn_check"></Button>
</LinearLayout>
.java
package com.EditText_2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class EditText_2Activity extends Activity {
/** Called when the activity is first created. */
private EditText t1=null;
private EditText t2=null;
private EditText t3=null;
private EditText t4=null;
private EditText t5=null;
private Button bt=null;
private String message=null;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
t1=(EditText)findViewById(R.id.num);
t2=(EditText)findViewById(R.id.apha);
t3=(EditText)findViewById(R.id.password);
t4=(EditText)findViewById(R.id.phone);
t5=(EditText)findViewById(R.id.multi);
bt=(Button)findViewById(R.id.btn);
}
public void btn_check(View v)
{
message=t1.getText().toString()+"\n"+t2.getText().toString()+"\n"+t3.getText().toString()+"\n"+t4.getText().toString()+"\n"+t5.getText().toString();
//Toast.makeText(getApplicationContext(),message,Toast.LENGTH_SHORT).show();
Intent i =new Intent(getApplicationContext(),welcome.class);
i.putExtra("message",message);
startActivity(i);
}
}
welcome.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:text="" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="300sp" android:layout_height="300sp" android:id="@+id/textView"></TextView>
</LinearLayout>
welcome.java
package com.EditText_2;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class welcome extends Activity
{
private TextView tv=null;
public void onCreate(Bundle savednstanceState)
{
super.onCreate(savednstanceState);
setContentView(R.layout.welcome);
tv=(TextView)findViewById(R.id.textView);
Bundle b=getIntent().getExtras();
tv.setText(b.getString("message"));
}
}
No comments:
Post a Comment