I'm an Android beginner and I have a little problem.
I have 2 radioButtons titled "Yes" and "No", 4 editTexts which are disabled and a button titled "Reset All".
Now, when I select the "No" radioButton, editTexts 1 and 2 become enabled and 1 gains focus. This is the desired behaviour. But When I select "Reset All" and again repeat the procedure, only editText 2 gets enabled and the "No" radioButton is still unchecked.
Following is my code:
MainActivity.java
package com.example.chris.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
public class MainActivity extends AppCompatActivity {
EditText e1;
EditText e2;
EditText e3;
EditText e4;
RadioButton yes;
RadioButton no;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1 = (EditText)findViewById(R.id.e1);
e2 = (EditText)findViewById(R.id.e2);
e3 = (EditText)findViewById(R.id.e3);
e4 = (EditText)findViewById(R.id.e4);
yes = (RadioButton)findViewById(R.id.yes);
no = (RadioButton)findViewById(R.id.no);
}
public void onClickreset(View v){
yes.setChecked(false);
no.setChecked(false);
e1.setEnabled(false);
e2.setEnabled(false);
e3.setEnabled(false);
e1.setText("");
e2.setText("");
e3.setText("");
e4.setText("");
};
public void onRadioButtonClicked(View v)
{
boolean checked = ((RadioButton) v).isChecked();
switch(v.getId()){
case R.id.yes:
if(checked)
e1.setEnabled(false);
e2.setEnabled(false);
e3.setEnabled(true);
e3.requestFocus();
break;
case R.id.no:
if(checked)
e1.setEnabled(true);
e2.setEnabled(true);
e2.requestFocus();
e2.clearFocus();
e3.setEnabled(false);
break;
}
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.chris.myapplication.MainActivity">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*">
<!-- Row 1 Starts From Here -->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:gravity="center"
android:orientation="horizontal">
<RadioButton
android:id="#+id/yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:checked="false"
android:onClick="onRadioButtonClicked"
android:text="yes" />
<RadioButton
android:id="#+id/no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:checked="false"
android:onClick="onRadioButtonClicked"
android:text="no" />
</RadioGroup>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="#+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="1:"
android:textColor="#000000" />
<EditText
android:id="#+id/e1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:enabled="false"
android:inputType="numberDecimal"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="#+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="2:"
android:textColor="#000000" />
<EditText
android:id="#+id/e2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:enabled="false"
android:inputType="numberDecimal"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="#+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="3:"
android:textColor="#000000" />
<EditText
android:id="#+id/e3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:enabled="false"
android:inputType="numberDecimal"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="#+id/t4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="10dp"
android:text="4:"
android:textColor="#000000" />
<EditText
android:id="#+id/e4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:enabled="false"
android:inputType="numberDecimal"
android:textColor="#000000" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="30dp" />
<Button
android:id="#+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_span="3"
android:gravity="center"
android:onClick="onClickreset"
android:text="Reset"
android:textAllCaps="false"
android:textColor="#000000"
android:textStyle="normal" />
</TableLayout>
</LinearLayout>
It's better to use RadioGroup.OnCheckedChangeListener, first of all, get rid of android:onClick attributes and assign an id to RadioGroup in XML:
<RadioGroup
android:id="#+id/yes_no_radio_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:gravity="center"
android:orientation="horizontal">
<RadioButton
android:id="#+id/yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:checked="false"
android:text="yes" />
<RadioButton
android:id="#+id/no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:checked="false"
android:text="no" />
</RadioGroup>
Then make your Activity implements RadioGroup.OnCheckedChangeListener and move there code from onRadioButtonClicked(View v) method:
public class MainActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {
//Some activity code
#Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch (radioGroup.getCheckedRadioButtonId()) {
case R.id.yes: //Not needed to
e1.setEnabled(false); //which RadioButton clicked
e2.setEnabled(false);
e3.setEnabled(true);
e3.requestFocus();
break;
case R.id.no:
e1.setEnabled(true);
e2.setEnabled(true);
e2.requestFocus();
e2.clearFocus();
e3.setEnabled(false);
break;
}
}
}
Then, assign OnCheckedChangeListener with RadioGroup:
yesNoGroup = findViewById(R.id.radio_group);
yesNoGroup.setOnCheckedChangeListener(this);
And change:
yes.setChecked(false);
no.setChecked(false);
To
yesNoGroup.clearCheck();
Related
Hi i'm trying to implement the following design (RadioGroup is parallel to TextView of rignt side)
for this requirement i wrote the bellow xml code
<RelativeLayout
android:id="#+id/rl_group_create_group_privacy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rl_group_create_group_icon"
android:layout_marginTop="10dp"
android:background="#drawable/rl_bg_board_group_create_group"
android:padding="10dp" >
<TextView
android:id="#+id/tv_group_create_group_privacy"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="#string/group_create_new_group_privacy"
android:textColor="#color/Black"
android:textSize="15sp" />
<RadioGroup
android:id="#+id/rg_group_create_group_privacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/tv_group_create_group_privacy"
android:orientation="vertical" >
<RadioButton
android:id="#+id/rb_group_create_group_public"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="#string/group_create_new_group_public"
android:textSize="12sp" />
<RadioButton
android:id="#+id/rb_group_create_group_closed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:checked="false"
android:text="#string/group_create_new_group_closed"
android:textSize="12sp" />
<RadioButton
android:id="#+id/rb_group_create_group_secret"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="19dp"
android:layout_weight="1"
android:checked="false"
android:text="#string/group_create_new_group_secret"
android:textSize="12sp" />
</RadioGroup>
<RelativeLayout
android:id="#+id/rl_group_create_group_privacy_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/rg_group_create_group_privacy"
android:background="#color/White" >
<TextView
android:id="#+id/tv_group_create_group_public_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/group_create_new_group_public_desc"
android:textColor="#color/Black"
android:textSize="12sp" />
<TextView
android:id="#+id/tv_group_create_group_closed_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_group_create_group_public_desc"
android:layout_marginTop="10dp"
android:text="#string/group_create_new_group_closed_desc"
android:textColor="#color/Black"
android:textSize="12sp" />
<TextView
android:id="#+id/tv_group_create_group_secret_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_group_create_group_closed_desc"
android:layout_marginTop="10dp"
android:text="#string/group_create_new_group_secret_desc"
android:textColor="#color/Black"
android:textSize="12sp" />
</RelativeLayout>
</RelativeLayout>
But it changing the alignment according to the device like the following picture (Some times radio button at middle of textView and some times at starting of textView and some more times at end of textView). By implementing the design in layout-large, layout-small, layout-xlarge we can achieve this some how but i don't want to follow. So, how to implement first image design without following layout-large, layout-small, layout-xlarge
I hope this may helpful to you
<LinearLayout
android:id="#+id/rl_group_create_group_privacy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rl_group_create_group_icon"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top">
<TextView
android:id="#+id/tv_group_create_group_privacy"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:gravity="center"
android:padding="5dp"
android:text="Privacy"
android:textColor="#000000"
android:textSize="15sp" />
<RadioButton
android:id="#+id/rb_group_create_group_public"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/tv_group_create_group_privacy"
android:checked="false"
android:gravity="center|start"
android:text="Public"
android:textSize="12sp" />
<TextView
android:id="#+id/tv_group_create_group_public_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/rb_group_create_group_public"
android:padding="5dp"
android:text="group_create_new_group_public_desc"
android:textColor="#000000"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top">
<RadioButton
android:id="#+id/rb_group_create_group_closed"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:checked="false"
android:text="Closed"
android:textSize="12sp" />
<TextView
android:id="#+id/tv_group_create_group_closed_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/rb_group_create_group_closed"
android:padding="5dp"
android:text="group_create_new_group_closed_desc"
android:textColor="#000000"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rl_group_create_group_privacy_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top">
<RadioButton
android:id="#+id/rb_group_create_group_secret"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:checked="false"
android:text="Secret"
android:textSize="12sp" />
<TextView
android:id="#+id/tv_group_create_group_secret_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/rb_group_create_group_secret"
android:padding="5dp"
android:text="group_create_new_group_secret_desc"
android:textColor="#000000"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
In Activity
final RadioButton rbPublic = (RadioButton) findViewById(R.id.rb_group_create_group_public);
final RadioButton rbCloses = (RadioButton) findViewById(R.id.rb_group_create_group_closed);
final RadioButton rbSecret = (RadioButton) findViewById(R.id.rb_group_create_group_secret);
rbPublic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
rbCloses.setChecked(!isChecked);
rbSecret.setChecked(!isChecked);
}
}
});
rbCloses.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
rbPublic.setChecked(!isChecked);
rbSecret.setChecked(!isChecked);
}
}
});
rbSecret.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
rbCloses.setChecked(!isChecked);
rbPublic.setChecked(!isChecked);
}
}
});
I have cleared many problems about radio buttons but this was in my mind since many days. I have 5 radio buttons in different list view please tell me how to uncheck any radio button while accessing other and get the value of selected radio button.
following are the codes.
custom_dialogue.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="HardcodedText,RtlHardcoded,NestedWeights,UselessParent" >
<LinearLayout
android:layout_width="350dp"
android:layout_height="400dp"
android:background="#000000"
android:orientation="vertical"
android:weightSum="8" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#E3EBED"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:text="Screen timeout"
android:textColor="#449BA4"
android:textSize="21sp" />
</LinearLayout>
<RadioGroup
android:id="#+id/rg_all"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#F5F5F5"
android:orientation="horizontal"
android:weightSum="10" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="9"
android:text="15 seconds"
android:textColor="#000000"
android:textSize="18sp"
tools:ignore="HardcodedText" />
<RadioButton
android:id="#+id/rb_15sec"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#F5F5F5"
android:orientation="horizontal"
android:weightSum="10" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="9"
android:text="30 seconds"
android:textColor="#000000"
android:textSize="18sp"
tools:ignore="HardcodedText" />
<RadioButton
android:id="#+id/rb_30sec"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#F5F5F5"
android:orientation="horizontal"
android:weightSum="10" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="9"
android:text="1 minute"
android:textColor="#000000"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_1min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#F5F5F5"
android:orientation="horizontal"
android:weightSum="10" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="9"
android:text="2 minutes"
android:textColor="#000000"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_2min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#F5F5F5"
android:orientation="horizontal"
android:weightSum="10" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="9"
android:text="5 minutes"
android:textColor="#000000"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_5min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:checked="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#F5F5F5"
android:orientation="horizontal"
android:weightSum="10" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="9"
android:text="10 minutes"
android:textColor="#000000"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_10min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
</LinearLayout>
</RadioGroup>
<LinearLayout
android:id="#+id/ll_cancel"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:background="#C9DCE0"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Cancel"
android:textColor="#000000"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
CustomDialogue.java
package com.example.coustomdialogue;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;
public class CustomDialogue extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_dialogue);
final RadioGroup rg = (RadioGroup) findViewById(R.id.rg_all);
final RadioButton rb1 = (RadioButton)findViewById(R.id.rb_10min);
final RadioButton rb2 = (RadioButton)findViewById(R.id.rb_15sec);
final RadioButton rb3 = (RadioButton)findViewById(R.id.rb_1min);
final RadioButton rb4 = (RadioButton)findViewById(R.id.rb_2min);
final RadioButton rb5 = (RadioButton)findViewById(R.id.rb_30sec);
final RadioButton rb6 = (RadioButton)findViewById(R.id.rb_5min);
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if(checkedId == R.id.rb_10min){
rg.clearCheck();
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
rb5.setChecked(false);
rb6.setChecked(false);
}else if(checkedId == R.id.rb_15sec){
rg.clearCheck();
rb1.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
rb5.setChecked(false);
rb6.setChecked(false);
}else if(checkedId == R.id.rb_1min){
rg.clearCheck();
rb2.setChecked(false);
rb4.setChecked(false);
rb1.setChecked(false);
rb5.setChecked(false);
rb6.setChecked(false);
}else if(checkedId == R.id.rb_2min){
rg.clearCheck();
rb2.setChecked(false);
rb3.setChecked(false);
rb5.setChecked(false);
rb1.setChecked(false);
rb6.setChecked(false);
}else if(checkedId == R.id.rb_30sec){
rg.clearCheck();
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
rb6.setChecked(false);
rb1.setChecked(false);
}else{
rg.clearCheck();
rb2.setChecked(false);
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
rb5.setChecked(false);
rb1.setChecked(false);
}
}
});
}
}
I got the real Answer for the following I solved my problem as I used a Click event on every radio button. Whenever I click on the radio Button at that time i change the checked to uncheck if any. No need to use RadioGroup.
Hope this helped you all.
I want to add radio buttons such that only one of them is selected at a time among 4 buttons and I want to place them as:
RadioButton1 RadioButton2
RadioButton3 RadioButton4
I am trying the following code but 1&2 forms a grp and 3&4 forms a different grp and there are two value selected a time. Can anyone check it and share the correct way to do it?
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/apple" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/rdogrp_main"
android:orientation="vertical"
>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rdogrp1"
android:orientation="horizontal"
>
<RadioButton
android:id="#+id/RadioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Orange"
android:textColor="#000000"
/>
<RadioButton
android:id="#+id/RadioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="BlueBerry"
android:textColor="#000000"
/>
</RadioGroup>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rdogrp2"
android:orientation="horizontal"
>
<RadioButton
android:id="#+id/RadioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apple "
android:textColor="#000000"
/>
<RadioButton
android:id="#+id/RadioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="Santra :P"
android:textColor="#000000"
/>
</RadioGroup>
</RadioGroup>
</LinearLayout>
Ok I find a solution for you:
I know it is not the best solution but it works! :)
Just copy the xml file and activity code bellow:
Activity:
package com.example.stackoverflow;
import android.os.Bundle;
import android.app.Activity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.RadioButton;
public class MainActivity extends Activity {
private static String TAG = "MainActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RadioButton radiobutton1 = (RadioButton) findViewById(R.id.RadioButton1);
final RadioButton radiobutton2 = (RadioButton) findViewById(R.id.RadioButton2);
final RadioButton radiobutton3 = (RadioButton) findViewById(R.id.RadioButton3);
final RadioButton radiobutton4 = (RadioButton) findViewById(R.id.RadioButton4);
radiobutton1.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
radiobutton1.setChecked(true);
radiobutton2.setChecked(false);
radiobutton3.setChecked(false);
radiobutton4.setChecked(false);
return true;
}
});
radiobutton2.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
radiobutton2.setChecked(true);
radiobutton1.setChecked(false);
radiobutton3.setChecked(false);
radiobutton4.setChecked(false);
return true;
}
});
radiobutton3.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
radiobutton3.setChecked(true);
radiobutton1.setChecked(false);
radiobutton2.setChecked(false);
radiobutton4.setChecked(false);
return true;
}
});
radiobutton4.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
radiobutton4.setChecked(true);
radiobutton1.setChecked(false);
radiobutton2.setChecked(false);
radiobutton3.setChecked(false);
return true;
}
});
}
}
activity_main.xml :
<RelativeLayout 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"
tools:context=".MainActivity" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#FFDDDDDD" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioGroup
android:id="#+id/rdogrp1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Orange"
android:textColor="#000000" />
<RadioButton
android:id="#+id/RadioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="BlueBerry"
android:textColor="#000000" />
</RadioGroup>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioGroup
android:id="#+id/rdogrp2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Apple "
android:textColor="#000000" />
<RadioButton
android:id="#+id/RadioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="Santra :P"
android:textColor="#000000" />
</RadioGroup>
</TableRow>
</TableLayout>
</RelativeLayout>
For that you need to create only one RadioGroup and add four different RadioButton.
And for adding UI refer this url : Manage Layout Inside a Horizontal Oriented Radiogroup .
I hope this will help you.
Try Like this..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RadioGroup
android:id="#+id/rdogrp_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:text="India"
android:textColor="#000000" />
<RadioButton
android:id="#+id/RadioButton2"
android:layout_width="74dp"
android:layout_height="wrap_content"
android:layout_weight="0.57"
android:text="Austraila"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Srilanka "
android:textColor="#000000" />
<RadioButton
android:id="#+id/RadioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.48"
android:text="SouthAfrica"
android:textColor="#000000" />
</LinearLayout>
</RadioGroup>
</LinearLayout>
Let me know if you solve the problem...
I've look in the android documentation on how to implement alertdialog with a xml layout
here is the documentation
when i run the program and click the todo button the program crashes can anyone help?
here's my source code:
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class StartMoving extends Activity implements OnClickListener {
Button todo;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.start_moving);
todo = (Button) findViewById(R.id.bTodo);
todo.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.bTodo:
AlertDialog.Builder builder;
AlertDialog alertDialog;
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.to_do_list, null);
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();
alertDialog.show();
break;
default:
break;
}
}
}
here's the xml file named to_do_list.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:orientation="vertical"
android:weightSum="100" >
<ScrollView
android:id="#+id/svTips"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="87" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tvTipsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:text="#string/tips"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvtmb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/two_months_before"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvtmbSAP"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tmb_sort_and_purge"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvtmb_sap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/tmb_sap_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvtmbR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tmb_research"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvtmb_r_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/tmb_r_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvtmbCAMB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tmb_create_a_moving_builder"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvtmb_camb_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/tmb_camb_content" />
<TextView
android:id="#+id/tvswb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/six_weeks_before"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvswb_ordersupplies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/swb_order_supplies"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvswb_os_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/swb_os_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvswb_use_it_or_lose_it"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/swb_use_it_or_lose_it"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvswb_uioli_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/swb_uioli_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvswb_take_measurement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/swb_take_measurement"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvswb_tm_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/swb_tm_content" />
<TextView
android:id="#+id/tvomb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/one_month_before"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvomb_choose_your_mover_and_confirm_the_arragements"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/omb_choose_your_mover_and_confirm_the_arragements"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvomb_cymacta_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/omb_cymacta_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvomb_begin_packing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/omb_begin_paking"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvomb_bp_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/omb_bp_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvomb_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/omb_label"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvomb_l_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/omb_l_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvomb_separate_values"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/omb_separate_values"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvomb_sv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/omb_sv_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvomb_do_a_change_of_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/omb_do_a_change_of_address"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvomb_dacoa_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/omb_dacoa_content" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvomb_notify_important_parties"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/omb_notify_all_important_parties"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/tvomb_naip_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/omb_naip_content" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="13"
android:orientation="horizontal" >
<Button
android:id="#+id/bReturntoTop"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="50"
android:text="Go back to top" />
<Button
android:id="#+id/bgoto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="50"
android:text="Go to" />
</LinearLayout>
</LinearLayout>
this is what the logcat shows
use
Context mContext = v.getApplicationContext();
instead of
Context mContext = getApplicationContext();
or
builder = new AlertDialog.Builder(StartMoving.this);
EDIT :
You are reading button
todo = (Button) findViewById(R.id.bgoto); <-----------
^^^^^
todo.setOnClickListener(this);
AlertDialog.Builder diag = new AlertDialog.Builder(this);
diag.setTitle("DIALOG TITLE")
.setMessage("YOUR MESSAGE")
.setCancelable(false)
.setNegativeButton("WHAT EVER THE BUTTON TEXT",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//enter code here
//do what ever the button in the dialog is clicked
dialog.cancel();
}
});
diag.show();
Easiest way to have a alert dialog
and dont forget to change the Button id in java to R.id.goto
if your are using alertDialog in TabHost then you have to write..
final AlertDialog alertDialog = new AlertDialog.Builder(**getParent()**).create();
//alertDialog.setTitle("Alert....");
alertDialog.setMessage("Your Text");
alertDialog.setButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1)
{
finish();
}
});
alertDialog.show();
It seems that I've been reading the button from the Context and not from the alertDialog. The solution was to create a View that will be set as View for the AlertDialog and declare a button and set it as a child for the View.
final View view;
LayoutInflater inf = LayoutInflater.from(StartMoving.this);
view = inf.inflate(R.layout.rename, null);
final EditText newname = (EditText) view.findViewById(R.id.etNewRoomName);
final Button todo = (BUtton) view.findViewById(R.id.bTodo);
new AlertDialog.Builder(StartMoving.this)
.setView(view)
.setTitle("Rename")
.setMessage("Enter new name for room " + currentRoom)
.show();
I have a very simple MainActivity, and from that Activity I start the other Activity (with theme Dialog so it floats on top of the MainActivity.
The problem is that there is always a delay before the second Activity show up. I'd say it takes almost 1 second for it to show, and there is no code at all in second Activity. The only code in the second Activity is this:
package MyPackage;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class JobViewActivity extends Activity {
#Override
protected void onCreate(android.os.Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.jobview);
}
#Override
protected void onResume() {
super.onResume();
}
}
The MainActivity has a ListView with Nodes, and there is a click listener connected to the ListView in the onCreate like this:
public void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
_nodeRowAdapter = new NodeRowAdapter(this, _nodes);
listView = (ListView)findViewById(R.id.ListViewNodes);
listView.setAdapter(_nodeRowAdapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getApplicationContext(), JobViewActivity.class);
startActivity(i);
}
});
But when the ListItem is pressed, and the Click listener is triggered, it takes about 1 second to show the "popup".
The layout isn't very advanced in the popup. Here is the layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="1"
android:stretchColumns="1" android:orientation="vertical">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:stretchColumns="1" android:layout_height="wrap_content" android:id="#+id/tableLayout1">
<TableRow>
<TextView
android:text="Id: "
android:padding="10dip"/>
<TextView
android:text="Ext id: "
android:gravity="right"
android:padding="10dip" />
</TableRow>
</TableLayout>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:id="#+id/relativeLayout1">
<LinearLayout android:id="#+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#E7F3F1">
<Button android:text="Start" android:id="#+id/button1" style="#style/ButtonText" android:layout_weight="1" android:background="#drawable/button_green"></Button>
<Button android:text="Bom" android:id="#+id/button2" style="#style/ButtonText" android:layout_weight="1" android:background="#drawable/button_red"></Button>
<Button android:text="Mer" android:id="#+id/button3" style="#style/ButtonText" android:layout_weight="1" android:background="#drawable/button_yellow"></Button>
<Button android:text="Nav" android:id="#+id/button4" style="#style/ButtonText" android:layout_weight="1"></Button>
</LinearLayout>
</RelativeLayout>
<RelativeLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_below="#+id/tableLayout1" android:layout_alignParentLeft="true" android:layout_above="#+id/relativeLayout1" android:padding="6dip">
<TextView style="#style/JobViewHeader" android:id="#+id/textView1" android:text="Something: "></TextView>
<TextView style="#style/JobViewHeader" android:id="#+id/TextView2" android:text="Something: " android:layout_below="#+id/textView1"></TextView>
<TextView style="#style/JobViewHeader" android:id="#+id/TextView3" android:layout_marginTop="16dp" android:text="Kund: " android:layout_below="#+id/TextView2"></TextView>
<TextView style="#style/JobViewHeader" android:id="#+id/TextView4" android:text="Something: " android:layout_below="#+id/TextView3"></TextView>
<TextView style="#style/JobViewHeader" android:id="#+id/TextView5" android:text="Something: " android:layout_below="#+id/TextView4"></TextView>
<TextView style="#style/JobViewHeader" android:id="#+id/TextView6" android:text="Something: " android:layout_below="#+id/TextView5"></TextView>
<TextView style="#style/JobViewHeader" android:id="#+id/TextView7" android:text="Something: " android:layout_below="#+id/TextView6"></TextView>
<TextView style="#style/JobViewHeader" android:id="#+id/TextView8" android:layout_marginTop="20dp" android:text="Something: " android:layout_below="#+id/TextView7"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_alignBaseline="#+id/textView1" android:layout_alignBottom="#+id/textView1" android:layout_toRightOf="#+id/textView1" android:id="#+id/textViewPickuptime"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_alignBaseline="#+id/TextView2" android:layout_alignBottom="#+id/TextView2" android:layout_toRightOf="#+id/TextView2" android:id="#+id/textViewPickupAddress"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_above="#+id/TextView4" android:layout_toRightOf="#+id/TextView3" android:id="#+id/textViewCustomer"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_alignBaseline="#+id/TextView4" android:layout_alignBottom="#+id/TextView4" android:layout_toRightOf="#+id/TextView4" android:id="#+id/textViewNbrOfPassengers"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_above="#+id/TextView6" android:layout_toRightOf="#+id/TextView5" android:id="#+id/textViewRoutine"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_alignBaseline="#+id/TextView6" android:layout_alignBottom="#+id/TextView6" android:layout_toRightOf="#+id/TextView6" android:id="#+id/textViewServiceFee"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_alignBaseline="#+id/TextView7" android:layout_alignBottom="#+id/TextView7" android:layout_toRightOf="#+id/TextView7" android:id="#+id/textViewHelp"></TextView>
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:layout_below="#+id/TextView8" android:layout_alignLeft="#+id/TextView8" android:id="#+id/textViewExtra"></TextView>
</RelativeLayout>
</RelativeLayout>
Im not sure what else to tell you, there isnt much more too it.
Im testing on a device, Samsung Galaxy S2.