Here in this we design UserInterface in Android,
It displays from,to edittext boxs,when user clicks one edit(e.g from) textbox then a layout display on position of that Edittext box(e.g from)
-> All the values in layout are Edittext boxes only..
-> After entering all values in Edittext boxs press done btn,then text in all edittext boxs of layout displayed on parent Edittext box..and clear btn clears all data on edittext boxes..
Note : If any drawables are missing then add ur Desired drawable with specified size(width,hight)..
SnailMailUIDesignActivity.java:-
package org.dharani.SnailMailUI;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
public class SnailMailUIDesignActivity extends Activity {
int i=0;
EditText fromTitleEdtTxt,toTitleEdtTxt;
Button fromDoneBtn,fromClearBtn,toDoneBtn,toClearBtn;
EditText fromfrstNameEdtTxt,frommiddleNameEdtTxt,fromlastNameEdtTxt,fromaddress1EdtTxt,fromaddress2EdtTxt,fromcityEdtTxt,fromstateEdtTxt,fromzipEdtTxt;
EditText tofrstNameEdtTxt,tomiddleNameEdtTxt,tolastNameEdtTxt,toaddress1EdtTxt,toaddress2EdtTxt,tocityEdtTxt,tostateEdtTxt,tozipEdtTxt;
LinearLayout fromTitleLayout,fromBodyLayout,toTitleLayout,toBodyLayout;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.address_fields);
getAllIds();
}
private void getAllIds() {
// TODO Auto-generated method stub
fromTitleLayout=(LinearLayout)findViewById(R.id.fromTitleLayout);
fromBodyLayout=(LinearLayout)findViewById(R.id.fromBodyLayout);
fromBodyLayout.setVisibility(View.GONE);
toTitleLayout=(LinearLayout)findViewById(R.id.toTitleLayout);
toBodyLayout=(LinearLayout)findViewById(R.id.toBodyLayout);
toBodyLayout.setVisibility(View.GONE);
fromDoneBtn=(Button)findViewById(R.id.fromDoneBtn);
fromDoneBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(fromfrstNameEdtTxt.getText().toString().trim().length()>0 &&
frommiddleNameEdtTxt.getText().toString().trim().length()>0 &&
fromlastNameEdtTxt.getText().toString().trim().length()>0 &&
fromaddress1EdtTxt.getText().toString().trim().length()>0 &&
fromaddress2EdtTxt.getText().toString().trim().length()>0 &&
fromcityEdtTxt.getText().toString().trim().length()>0 &&
fromstateEdtTxt.getText().toString().trim().length()>0 &&
fromzipEdtTxt.getText().toString().trim().length()>0){
fromBodyLayout.setVisibility(View.GONE);
fromTitleLayout.setVisibility(View.VISIBLE);
fromTitleEdtTxt.setText("From : "+fromfrstNameEdtTxt.getText().toString()+" "+frommiddleNameEdtTxt.getText().toString()
+" "+fromlastNameEdtTxt.getText().toString()
+" "+fromaddress1EdtTxt.getText().toString()
+" "+fromaddress2EdtTxt.getText().toString()
+" "+fromcityEdtTxt.getText().toString()
+" "+fromstateEdtTxt.getText().toString()
+" "+fromzipEdtTxt.getText().toString());
}else{
Toast.makeText(getApplicationContext(), "please fill mandatory fields",Toast.LENGTH_LONG).show();
}
}
});
fromClearBtn=(Button)findViewById(R.id.fromClearBtn);
fromClearBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fromfrstNameEdtTxt.setText("");
frommiddleNameEdtTxt.setText("");
fromlastNameEdtTxt.setText("");
fromaddress1EdtTxt.setText("");
fromaddress2EdtTxt.setText("");
fromcityEdtTxt.setText("");
fromstateEdtTxt.setText("");
fromzipEdtTxt.setText("");
}
});
toDoneBtn=(Button)findViewById(R.id.toDoneBtn);
toDoneBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(tofrstNameEdtTxt.getText().toString().trim().length()>0 &&
tomiddleNameEdtTxt.getText().toString().trim().length()>0 &&
tolastNameEdtTxt.getText().toString().trim().length()>0 &&
toaddress1EdtTxt.getText().toString().trim().length()>0 &&
toaddress2EdtTxt.getText().toString().trim().length()>0 &&
tocityEdtTxt.getText().toString().trim().length()>0 &&
tostateEdtTxt.getText().toString().trim().length()>0 &&
tozipEdtTxt.getText().toString().trim().length()>0){
toBodyLayout.setVisibility(View.GONE);
toTitleLayout.setVisibility(View.VISIBLE);
toTitleEdtTxt.setText("To : "+tofrstNameEdtTxt.getText().toString()+" "+tomiddleNameEdtTxt.getText().toString()
+" "+tolastNameEdtTxt.getText().toString()
+" "+toaddress1EdtTxt.getText().toString()
+" "+toaddress2EdtTxt.getText().toString()
+" "+tocityEdtTxt.getText().toString()
+" "+tostateEdtTxt.getText().toString()
+" "+tozipEdtTxt.getText().toString());
}else{
Toast.makeText(getApplicationContext(), "please fill mandatory fields",Toast.LENGTH_LONG).show();
}
}
});
toClearBtn=(Button)findViewById(R.id.toClearBtn);
toClearBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tofrstNameEdtTxt.setText("");
tomiddleNameEdtTxt.setText("");
tolastNameEdtTxt.setText("");
toaddress1EdtTxt.setText("");
toaddress2EdtTxt.setText("");
tocityEdtTxt.setText("");
tostateEdtTxt.setText("");
tozipEdtTxt.setText("");
}
});
//all edit text boxes
fromfrstNameEdtTxt=(EditText)findViewById(R.id.fromfrstNameEdtTxt);
frommiddleNameEdtTxt=(EditText)findViewById(R.id.frommiddleNameEdtTxt);
fromlastNameEdtTxt=(EditText)findViewById(R.id.fromlastNameEdtTxt);
fromaddress1EdtTxt=(EditText)findViewById(R.id.fromaddress1EdtTxt);
fromaddress2EdtTxt=(EditText)findViewById(R.id.fromaddress2EdtTxt);
fromcityEdtTxt=(EditText)findViewById(R.id.fromcityEdtTxt);
fromstateEdtTxt=(EditText)findViewById(R.id.fromstateEdtTxt);
fromzipEdtTxt=(EditText)findViewById(R.id.fromzipEdtTxt);
tofrstNameEdtTxt=(EditText)findViewById(R.id.tofrstNameEdtTxt);
tomiddleNameEdtTxt=(EditText)findViewById(R.id.tomiddleNameEdtTxt);
tolastNameEdtTxt=(EditText)findViewById(R.id.tolastNameEdtTxt);
toaddress1EdtTxt=(EditText)findViewById(R.id.toaddress1EdtTxt);
toaddress2EdtTxt=(EditText)findViewById(R.id.toaddress2EdtTxt);
tocityEdtTxt=(EditText)findViewById(R.id.tocityEdtTxt);
tostateEdtTxt=(EditText)findViewById(R.id.tostateEdtTxt);
tozipEdtTxt=(EditText)findViewById(R.id.tozipEdtTxt);
fromTitleEdtTxt=(EditText)findViewById(R.id.fromTitleEdtTxt);
fromTitleEdtTxt.setFocusable(false);
fromTitleEdtTxt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("---------clicked--------");
fromTitleLayout.setVisibility(View.GONE);
fromBodyLayout.setVisibility(View.VISIBLE);
toBodyLayout.setVisibility(View.GONE);
toTitleLayout.setVisibility(View.VISIBLE);
}
});
toTitleEdtTxt=(EditText)findViewById(R.id.toTitleEdtTxt);
toTitleEdtTxt.setFocusable(false);
toTitleEdtTxt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("---------clicked--------");
toTitleLayout.setVisibility(View.GONE);
toBodyLayout.setVisibility(View.VISIBLE);
fromBodyLayout.setVisibility(View.GONE);
fromTitleLayout.setVisibility(View.VISIBLE);
}
});
//fromTitleLayout.setClickable(true);
/*fromTitleLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("---------clicked--------");
fromTitleLayout.setVisibility(View.GONE);
fromBodyLayout.setVisibility(View.VISIBLE);
}
});*/
}//getAllIds()...
}
address_fields.xml:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="62dip"
>
<Button
android:id="@+id/resetBtn"
android:layout_width="wrap_content"
android:layout_height="35dip"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dip"
android:clickable="true"
android:gravity="center"
android:text="Discard"
android:textStyle="normal"
android:onClick="resetBtnClick"/>
<TextView
android:id="@+id/firstedittext"
android:layout_width="wrap_content"
android:layout_height="62dip"
android:layout_centerInParent="true"
android:gravity="center"
android:text="Add Job Screen"
android:textSize="15dip"
android:textStyle="bold" >
</TextView>
<Button
android:id="@+id/continueBtn"
android:layout_width="wrap_content"
android:layout_height="35dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dip"
android:gravity="center"
android:text="Send"
android:textStyle="normal"
>
</Button>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal"
android:paddingRight="5dip" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<Button
android:id="@+id/refreshbtn"
android:layout_width="20dip"
android:layout_height="20dip"
android:background="@drawable/refreshx" />
</LinearLayout>
<TextView
android:id="@+id/showJobsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="List"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/showPricing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Pricing"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/showHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Help"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/showCreditCards"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:text="CreditCards"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/showSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="@+id/fromTitleLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="fromTitleLayoutClick"
android:gravity="center_vertical"
android:orientation="horizontal">
<EditText android:id="@+id/fromTitleEdtTxt"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:paddingLeft="4dip"
android:background="#00000000" android:layout_weight="1"
android:hint="From : " />
<Button android:layout_width="30dip"
android:layout_height="30dip"
android:layout_marginRight="30dip"
android:clickable="true"
android:onClick="pickContactAddressForFromAddress"
/>
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout android:id="@+id/fromBodyLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:orientation="horizontal" >
<EditText android:id="@+id/fromBodyEdtTxt"
android:layout_width="60dip"
android:layout_height="fill_parent"
android:gravity="top"
android:paddingTop="12dip"
android:paddingLeft="4dip"
android:background="#00000000"
android:hint="From:" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<EditText android:id="@+id/fromfrstNameEdtTxt"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#00000000"
android:paddingLeft="4dip"
android:hint="First name"/>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:hint="Middle Name"
android:id="@+id/frommiddleNameEdtTxt"
android:background="#00000000"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:paddingLeft="4dip"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="Last Name"
android:id="@+id/fromlastNameEdtTxt"
android:background="#00000000"
android:paddingLeft="4dip"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_weight="1" />
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout android:id="@+id/addressLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:hint="Address Line1"
android:id="@+id/fromaddress1EdtTxt"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:paddingLeft="4dip"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="Address Line2"
android:id="@+id/fromaddress2EdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout android:id="@+id/cityStateZipLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:hint="City"
android:id="@+id/fromcityEdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:layout_height="50dip"
android:background="#00000000"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="State"
android:id="@+id/fromstateEdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="Zip"
android:id="@+id/fromzipEdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:text="Done"
android:id="@+id/fromDoneBtn"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
<!-- <View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/> -->
<Button
android:text="Clear"
android:id="@+id/fromClearBtn"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
<!-- <View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<Button
android:text="Temp"
android:id="@+id/tempBtn"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" /> -->
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<!-- To header text start from hetre -->
<LinearLayout android:id="@+id/toTitleLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<EditText android:id="@+id/toTitleEdtTxt"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:paddingLeft="4dip"
android:background="#00000000" android:layout_weight="1"
android:hint="To : " />
<Button android:layout_width="30dip"
android:layout_height="30dip"
android:layout_marginRight="30dip"
android:clickable="true"
android:onClick="pickContactAddressForToAddress"
/>
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout android:id="@+id/toBodyLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:orientation="horizontal" >
<EditText android:id="@+id/toBodyEdtTxt"
android:layout_width="60dip"
android:layout_height="fill_parent"
android:gravity="top"
android:paddingTop="12dip"
android:paddingLeft="4dip"
android:background="#00000000"
android:hint="To:" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<EditText android:id="@+id/tofrstNameEdtTxt"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#00000000"
android:paddingLeft="4dip"
android:hint="First name"/>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:hint="Middle Name"
android:id="@+id/tomiddleNameEdtTxt"
android:background="#00000000"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:paddingLeft="4dip"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="Last Name"
android:id="@+id/tolastNameEdtTxt"
android:background="#00000000"
android:paddingLeft="4dip"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_weight="1" />
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout android:id="@+id/toaddressLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:hint="Address Line1"
android:id="@+id/toaddress1EdtTxt"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:paddingLeft="4dip"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="Address Line2"
android:id="@+id/toaddress2EdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout android:id="@+id/tocityStateZipLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:hint="City"
android:id="@+id/tocityEdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:layout_height="50dip"
android:background="#00000000"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="State"
android:id="@+id/tostateEdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
<View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<EditText
android:hint="Zip"
android:id="@+id/tozipEdtTxt"
android:layout_width="fill_parent"
android:paddingLeft="4dip"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:text="Done"
android:id="@+id/toDoneBtn"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
<!-- <View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/> -->
<Button
android:text="Clear"
android:id="@+id/toClearBtn"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" />
<!-- <View android:background="#D3D3D3"
android:layout_width="1dip"
android:layout_height="fill_parent"/>
<Button
android:text="Temp"
android:id="@+id/totempBtn"
android:layout_width="fill_parent"
android:background="#00000000"
android:layout_height="50dip"
android:layout_weight="1" /> -->
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/>
<EditText
android:id="@+id/bodyEditTxt"
android:layout_width="fill_parent"
android:layout_height="150dip"
android:gravity="top"
android:padding="5dip"
android:background="#00000000"
android:hint="Notes"
/>
<!-- <View android:background="#D3D3D3"
android:layout_width="fill_parent"
android:layout_height="1dip"/> -->
<Button
android:id="@+id/addFileBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="addFileBtnClick"
android:text="AddFiles" />
</LinearLayout>
Comments
Post a Comment