Android Keyboard appear after Tabbar - android

I have four tabs in my home screen and one of them takes user input,
I have a two problem one is when open tab activity then android keyboard automatically open
and another problem is keyboard coming after tabbar.
I already added android:windowSoftInputMode="adjustPan" in my menifetch file
I Share My code
My createchallan.xml code
<?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:orientation="vertical" >
<TextView
android:id="#+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="38dp"
android:text="Search" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/search"
android:layout_alignBottom="#+id/search"
android:layout_toRightOf="#+id/search"
android:background="#android:drawable/editbox_background"
android:layout_marginLeft="2dip"
android:singleLine="true"
android:ems="5" >
<requestFocus android:layout_width="wrap_content" />
</EditText>
<CheckBox
android:id="#+id/review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/search"
android:layout_alignParentRight="true"
android:layout_marginTop="6dip"
android:layout_alignBaseline="#+id/search"
android:text="Review Item" />
<RelativeLayout
android:id="#+id/header"
android:layout_marginTop="10dip"
android:layout_below="#+id/review"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E5E4E2"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtItemcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Code"
android:singleLine="true"
android:layout_marginLeft="3dip"
android:textStyle="bold"
/>
<TextView
android:id="#+id/txtItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_toRightOf="#+id/txtItemcode"
android:textStyle="bold"
android:text="Item" />
<TextView
android:id="#+id/txtItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="14dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:textStyle="bold"
android:text="Quantity" />
</RelativeLayout>
<LinearLayout
android:id="#+id/listlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header"
android:layout_above="#+id/lastbutton">
<ListView
android:id="#+id/createlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:cacheColorHint="#00000000"
android:divider="#adb8c2"
android:dividerHeight="1dp"
android:scrollingCache="false"
android:smoothScrollbar="true"
>
</ListView>
</LinearLayout>
<RelativeLayout
android:layout_alignParentBottom="true"
android:id="#+id/lastbutton"
android:layout_marginBottom="8dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/createcancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/createsavedraft"
android:background="#drawable/roundedbutton"
android:text=" Cancel " />
<Button
android:id="#+id/createsavedraft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/creatapprove"
android:background="#drawable/roundedbutton"
android:text=" Save Draft " />
<Button
android:id="#+id/creatapprove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/roundedbutton"
android:text=" Approve " />
</RelativeLayout>
my custom xml create_list_item.xml
<?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:orientation="horizontal" >
<TextView
android:id="#+id/txtItemcode"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:text="323232"
android:singleLine="true"
android:layout_marginTop="9dip"
android:layout_marginLeft="5dip"
android:textStyle="bold"
android:focusable="false"
android:focusableInTouchMode="false"
/>
<TextView
android:id="#+id/txtItem"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:layout_marginTop="9dip"
android:layout_marginLeft="25dp"
android:layout_toRightOf="#+id/txtItemcode"
android:layout_alignBaseline="#+id/txtItemcode"
android:text="5456455565456"
android:focusable="false"
android:focusableInTouchMode="false" />
<EditText
android:id="#+id/editcreateQuantity"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:drawable/editbox_background"
android:ems="10"
android:inputType="number"
android:layout_marginRight="5dip"
android:layout_alignBaseline="#+id/txtItemcode"
android:focusable="true"
android:singleLine="true" >
</EditText>
</RelativeLayout>
My java code
public class CreateChallan extends Activity {
ListView lstCreate;
String[] strmainItemCode;
String[] strItem;
String[] strQuantity;
Context context=this;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.createchallan);
lstCreate= (ListView) findViewById(R.id.createlist);
lstCreate.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
strmainItemCode= new String[]{"55555551","255555","355555","455555","555555"};
strItem =new String[]{"A","B","C","D","F"};
strQuantity =new String[]{"100","200","30","400","500"};
CreateAdapter adapter= new CreateAdapter(this, strmainItemCode, strItem, strQuantity);
lstCreate.setAdapter(adapter);
lstCreate.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position1, long id) {
// TODO Auto-generated method stub
Toast.makeText(context, "Position", Toast.LENGTH_LONG).show();
}
});
}
// Create List Adapter
class CreateAdapter extends ArrayAdapter<String>
{
TextView txtItecode, txtItem;
EditText editQuantity;
String[] strItecode;
String[] strItem;
String[] strQuantity;
Context context;
CreateAdapter(Context context, String[] strItemcode, String[] strItem, String[] strQauntity)
{
super(context,R.layout.create_list_item,R.id.txtItemcode,strItemcode);
this.context= context;
this.strItecode= strItemcode;
this.strItem= strItem;
this.strQuantity= strQauntity;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View row;
row=mInflater.inflate(R.layout.create_list_item, parent,false);
txtItecode= (TextView) row.findViewById(R.id.txtItemcode);
txtItem =(TextView) row.findViewById(R.id.txtItem);
editQuantity = (EditText) row.findViewById(R.id.editcreateQuantity);
editQuantity.setSelected(false);
txtItecode.setText(strItecode[position]);
txtItem.setText(strItem[position]);
editQuantity.setText(strQuantity[position]);
txtItecode.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "click", Toast.LENGTH_LONG).show();
}
});
return row;
}
}
}

below code on you manifest in TabHostActivity or tab parent activity..
android:windowSoftInputMode="adjustPan"

Hi try below code on you manifest for activity
android:windowSoftInputMode="adjustPan"
hope this will work,Thanks

Related

Listview displays only one row from the list

I am new to android listviews and I am trying to populate a listview in android by a list of items coming from a webservice. I know that the list contains more than one record coming from the webservice but my custom listview displays only the first record from the list. I checked the size of the list and there is always more than one records but the listview is showing only one of them. My custom adapter is like following:
public class ListAdapter extends BaseAdapter {
Context ctx;
LayoutInflater lInflater;
ArrayList<LItem> lstItems;
ListAdapter(Context context, ArrayList<LItem> objects) {
ctx = context;
lstItems = objects;
lInflater = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return lstItems.size();
}
#Override
public Object getItem(int position) {
return lstItems.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = lInflater.inflate(R.layout.list_style_task
, parent, false);
}
LItem p = getProduct(position);
((TextView) view.findViewById(R.id.tvMaterial )).setText(p.getMName() );
((TextView) view.findViewById(R.id.tvTask )).setText(p.getTName() );
((TextView) view.findViewById(R.id.tvBQuantity )).setText(p.getBQ() );
// CheckBox cbBuy = (CheckBox) view.findViewById(R.id.checkbox);
//cbBuy.setOnCheckedChangeListener(myCheckChangList);
// cbBuy.setTag(position);
// cbBuy.setChecked(p.selected);
return view;
}
LItem getProduct(int position)
{
return ((LItem) getItem(position));
}
ArrayList<LItem> getBox() {
ArrayList<LItem> box = new ArrayList<LItem>();
for (LItem p : lstItems) {
// if (p.selected)
// box.add(p);
}
return box;
}
OnCheckedChangeListener myCheckChangList = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
//getProduct((Integer) buttonView.getTag())= isChecked;
}
};
}
I am binding the listview as:
protected void onPostExecute(List<LItem> li ) {
super.onPostExecute(lstItm);
if(lstItm.size()>0) {
Adp=new ListAdapter(myactivity,lstItm);
lvTasks.setAdapter(Adp);
Log.d("Size---------",Integer.toString(lstItm.size()) );//here it writes more than one as size of the list.
}
}
My xml file for displaying lists is 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"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
>
<CheckBox
android:id="#+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:focusable="false"
android:textColor="#FFF"
android:button="#drawable/custom_checkbox_design"
android:focusableInTouchMode="false"
android:text="" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Task:"
android:id="#+id/textView2"
android:layout_weight="1"
android:textColor="#FFF"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="task"
android:id="#+id/tvTask"
android:layout_weight="1"
android:textColor="#FFF"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:layout_marginRight="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Material:"
android:id="#+id/textView1"
android:layout_weight="1"
android:textColor="#FFF"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="material"
android:id="#+id/tvMaterial"
android:layout_weight="1"
android:textColor="#FFF"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="45dp"
android:layout_marginRight="20dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Balanced Quantity:"
android:id="#+id/textView14"
android:layout_weight="1"
android:textColor="#FFF"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bquantity"
android:id="#+id/tvBQuantity"
android:layout_weight="1"
android:textColor="#FFF"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:layout_marginRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Adjust Balanced Quantity:"
android:id="#+id/textView25"
android:layout_weight="1"
android:textColor="#FFF"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/tvAQuantity"
android:layout_weight="1"
android:textColor="#FFF"
/>
</LinearLayout>
</LinearLayout>
My xml for listview is like this:
<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"
tools:context="kanix.highrise.com.highrise.generate_material_requisition">
<!-- TODO: Update blank fragment layout -->
<ScrollView android:id="#+id/ScrlView" android:layout_width="fill_parent" android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/lstTaskQuantity"
android:layout_weight="1" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView
android:id="#+id/txtLddsdfabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="16dp"
android:text="Req. From :"
android:layout_weight="1"
android:textColor="#fff" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:id="#+id/etDate"
android:layout_weight=".5"
android:hint="DD/MM/YYYY"/>
<ImageButton
android:layout_width="35dp"
android:layout_height="35dp"
android:id="#+id/btnimgcal"
android:src="#drawable/calender"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView
android:id="#+id/txtLddsdfadsbel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="16dp"
android:text="For Days :"
android:layout_weight="1"
android:textColor="#fff" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:text="0"
android:id="#+id/editText"
android:layout_weight="1.69" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView
android:id="#+id/txtLddsddfgfadsbel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="16dp"
android:text="Quantity :"
android:layout_weight="1"
android:textColor="#fff" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:text="0"
android:id="#+id/etQuantity"
android:layout_weight="1.60" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:orientation="vertical"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#0080FF"
android:background="#fff"
android:text="Generate Requisition"
android:id="#+id/btnSave" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Issue was with the scrollview which was createing the issue. I just removed
<ScrollView android:id="#+id/ScrlView" android:layout_width="fill_parent" android:layout_height="fill_parent" >
</ScrollView>
and it worked for me :)

Displaying data in listview

I am trying to design a listview wherein i have to display two to three data for rows of each column,but i am not able to do so,i am getting the data has in image a but i want to display has in image b,i can display only single data in each row of each column.For example the column states to display the value of item number and style number ,i am able to display only item number but not style number.
**DataDisplay xml**
<?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="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView3"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView4"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView5"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textSize="25dp"
android:text="TextView" />
</LinearLayout>
**Listview xml**
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:divider="#00000000"
android:dividerHeight="5dp"
/>
</LinearLayout>
adapter
public class CustomAdapter extends BaseAdapter{
String [] result;
String [] result1;
String [] result2;
String [] result3;
String [] result4;
Context context;
int [] imageId;
private static LayoutInflater inflater=null;
public CustomAdapter(ItemActivity mainActivity, String[] prgmNameList,String[] prgmNameList1,String[] prgmNameList2,String[] prgmNameList3,String[] prgmNameList4) {
// TODO Auto-generated constructor stub
result=prgmNameList;
result1=prgmNameList1;
result2=prgmNameList2;
result3=prgmNameList3;
result4=prgmNameList4;
context=mainActivity;
inflater = ( LayoutInflater )context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return result.length;
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
#Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public class Holder
{
TextView tv;
TextView tv1;
TextView tv2;
TextView tv3;
TextView tv4;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Holder holder=new Holder();
View rowView;
rowView = inflater.inflate(R.layout.tabitem, null);
holder.tv=(TextView) rowView.findViewById(R.id.textView1);
holder.tv1=(TextView)rowView.findViewById(R.id.textView2);
holder.tv2=(TextView) rowView.findViewById(R.id.textView3);
holder.tv3=(TextView) rowView.findViewById(R.id.textView4);
holder.tv4=(TextView) rowView.findViewById(R.id.textView5);
holder.tv.setText(result[position]);
holder.tv1.setText(result1[position]);
holder.tv2.setText(result2[position]);
holder.tv3.setText(result3[position]);
holder.tv4.setText(result4[position]);
rowView.setBackgroundColor(Color.parseColor("#F1F1FF"));
rowView.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "You Clicked "+result[position], Toast.LENGTH_LONG).show();
}
});
return rowView;
}
}
called from activity
public static String [] prgmNameList={"123456","456665","123445","5675343"};
public static String [] prgmNameList1={"15.56","15.562","15.67","15.455"};
public static String [] prgmNameList2={"9999","9999","9999","9999"};
public static String [] prgmNameList3={"99%","99%","99%","99%"};
public static String [] prgmNameList4={"9999","9999","9999","9999"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.itemlist);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.item);
context=this;
lv=(ListView) findViewById(R.id.listView);
lv.setAdapter(new CustomAdapter(this, prgmNameList,prgmNameList1,prgmNameList2,prgmNameList3,prgmNameList4));
}
You need to create a custom layout for your row item where you can place two textviews one below the other to show your data as you want. Then override the getView() method of your adapter and inflate this custom layout and populate it with data from an array / list.
See the getView() method in the link mentioned in giacavicchioli's answer.
As user87049 has said this will solve your problem sarah:
**DataDisplay xml**
<?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="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="2dp"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView3"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="2dp"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView4"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="2dp"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="#+id/textView5"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="2dp"
android:textSize="25dp"
android:text="TextView" />
</LinearLayout>
tell me if this this is not what you want :)
Ah and since I'm a bit busy these days and I may not come to this account on stackoverflow, please send me email to get my attention please [erfan.molaei#gmail.com]
Here is what i did. Make a xml file 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="horizontal"
android:layout_weight="1">
<LinearLayout
android:layout_width="100dp"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00FF00" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0000FF" />
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00FF00" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0000FF" />
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00FF00" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0000FF" />
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00FF00" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0000FF" />
</LinearLayout>
</LinearLayout>
This is your custom listview xml file. Now in getView method setText to this all textview as you did for your xml file.
Check out below screen:

how multiple selected spinner item data display on one editbox when I am click on button

when I am selected multiple spinner item that all data item display on one separated edit box. this is one part of code and xml.
public void addItemsOnSpinner(){
sp1=(Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.facility_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp1.setAdapter(adapter);
}
public void onItemSelected(AdapterView<?> spinner, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
switch(view.getId()){
//Spinner spinner1,spinner2,spinner3;
case R.id.spinner1:
Toast.makeText(myetms.this,"spinner1",Toast.LENGTH_LONG).show();
//break
case R.id.spinner2:
Toast.makeText(myetms.this,"spinner2",Toast.LENGTH_LONG).show();
//break;
case R.id.spinner3:
Toast.makeText(myetms.this,"spinner3",Toast.LENGTH_LONG).show();
break;
}
//sendSMS("9819861968","+location[index]");
//sc.setVisibility(view.VISIBLE); }
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
};
public void onItemSelected(AdapterView<?> sp1,View view,int pos,long id){
//sc.setText((CharSequence) sp1.getSelectedItem());
sc.setVisibility(view.VISIBLE);
}
Here is the xml file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="132dp"
android:src="#drawable/myshedule" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/TextView04"
android:layout_width="25dp"
android:layout_height="65dp"
android:layout_weight="1"
android:background="#dcdcdc"
android:gravity="center"
android:padding="20dip"
android:text="From"
android:textColor="#000000" />
<EditText
android:id="#+id/editText"
android:layout_width="55dp"
android:layout_weight="1"
android:background="#d3d3d3"
android:gravity="center"
android:padding="20dip"
android:text="Select Date"
android:textColor="#000000" />
<ImageButton
android:id="#+id/imageButton1"
android:layout_height="65dp"
android:contentDescription="#string/selectdate"
android:gravity="center"
android:padding="20dip"
android:src="#drawable/calendar_icon" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="35dp"
android:layout_weight="1"
android:background="#dcdcdc"
android:gravity="center"
android:padding="20dip"
android:text="Emplyee Name"
android:textColor="#000000" >
</TextView>
<EditText
android:id="#+id/screenName"
android:layout_width="45dp"
android:layout_height="50dp"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_weight="1" >
</EditText>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_height="65dp"
android:layout_weight="1"
android:background="#b0b0b0"
android:gravity="center"
android:padding="18dip"
android:text="Facility Type"
android:textColor="#000000" />
<Spinner
android:id="#+id/spinner1"
android:layout_height="65dp"
android:layout_weight="1"
android:background="#a09f9f"
android:entries="#array/facility_array"
android:gravity="center"
android:padding="18dip"
android:prompt="#string/facility_prompt"
android:textColor="#000000" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_height="65dp"
android:layout_weight="1"
android:background="#b0b0b0"
android:gravity="center"
android:padding="18dip"
android:text="Trip Type"
android:textColor="#000000" />
<Spinner
android:id="#+id/spinner2"
android:layout_height="65dp"
android:layout_weight="1"
android:background="#a09f9f"
android:entries="#array/trip_array"
android:gravity="center"
android:padding="18dip"
android:prompt="#string/trip_prompt"
android:textColor="#000000" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_height="65dp"
android:layout_weight="1"
android:background="#b0b0b0"
android:gravity="center"
android:padding="18dip"
android:text="Shift Type"
android:textColor="#000000" />
<Spinner
android:id="#+id/spinner3"
android:layout_height="65dp"
android:layout_weight="1"
android:background="#a09f9f"
android:entries="#array/shift_array"
android:gravity="center"
android:padding="18dip"
android:prompt="#string/shift_prompt"
android:textColor="#000000" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit" />
<Button
android:id="#+id/btnSubmit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/searchBox"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:inputType="textVisiblePassword"
android:paddingLeft="10dp" >
</EditText>
</LinearLayout>
</ScrollView>
Try this:
Globally define String Variable in which you need to store your different Spinner Selected Values.
Suppose you have 3 Spinners:
Then Define like:
String Spinner1Value,Spinner2Value,Spinner3Value;
before your
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.....
}
Now on Every Spinner setOnItemSelectedListener():
spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
try
{
Spinner1Value= spinner1.getSelectedItem().toString();
}
catch(Exception e)
{
Toast.makeText(getBaseContext(), "Error::"+e.toString(), Toast.LENGTH_LONG).show();
}
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
and after that you can get the selected values from Spinner1Value,Spinner2Value,Spinner3Value.
Like:
edittext1.setText(Spinner1Value+Spinner2Value+Spinner3Value);
Hope this may help you!

Android RelativeLayout not center

I have a problem about TextView in RelativeLayout is not center, (only some objects)
First, I'm use ListAdapter for ListView.
public class ListAdapter extends ArrayAdapter<Menu> {
private LayoutInflater inflater;
public ListAdapter(Context c, ArrayList<Menu> o) {
super(c, 0, o);
inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public View getView(int position, View v, ViewGroup parent) {
View view = null;
if (v == null) {
view = inflater.inflate(R.layout.row, null);
} else {
view = v;
}
final Menu data = this.getItem(position);
TextView title = (TextView) view.findViewById(R.id.title);
ImageView background = (ImageView) view.findViewById(R.id.background);
ImageView icon = (ImageView) view.findViewById(R.id.icon);
TextView subtitle = (TextView) view.findViewById(R.id.subtitle);
subtitle.setText(data.getSubTitle());
title.setText(data.getTitle());
background.setImageDrawable(data.getBackground());
icon.setImageDrawable(data.getIcon());
return view;
}
}
and, My row.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="75dip"
android:layout_height="82dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<ImageView
android:id="#+id/background"
android:layout_width="75dip"
android:layout_height="83dip"
android:src="#drawable/mediumorchid" />
<ImageView
android:id="#+id/icon"
android:layout_width="35dip"
android:layout_height="35dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_discard" />
</RelativeLayout>
<FrameLayout
android:id="#+id/fl1"
android:layout_width="75dip"
android:layout_height="80dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</FrameLayout>
<RelativeLayout
android:id="#+id/width"
android:layout_width="fill_parent"
android:layout_height="80dip"
android:layout_alignBottom="#+id/fl1"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/fl1"
android:layout_toRightOf="#+id/fl1"
android:background="#ecf0f1" >
<RelativeLayout
android:id="#+id/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="10dip"
android:text="Pure"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/title"
android:layout_marginTop="5dip"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</RelativeLayout>
<FrameLayout
android:id="#+id/frameLayout1"
android:layout_width="75dip"
android:layout_height="2dip"
android:layout_alignLeft="#+id/width"
android:layout_alignParentRight="true"
android:layout_below="#+id/width"
android:background="#drawable/cdivider" >
</FrameLayout>
This xml's Graphic Design
But in Device(example grouper) , i discover this problem.
In some object, (example see Help ~) Was centered properly. but, other objects, wasn't centered properly.
and i discover this problem another device(different resolution, size, Android version, density).
What can i do solve this problem??
Try this..
Add android:layout_centerHorizontal="true" for subtitle TextView
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/title"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:layout_centerHorizontal="true"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
or this
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_below="#+id/title"
android:layout_marginTop="5dip"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />

Handle same navigation drawer but change header text on every activity

Is there a way we can have same navigation drawer on each activity but with change in the header text? For instance I got two activities, my home activity will display a header text as home and my "about us" activity will display "about us" header text but all will have the same navigation settings.
BaseActivity
#TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public class BaseActivity extends Activity {
ExpandableListAdapter listAdapter;
ExpandableListView expListView;
public DrawerLayout drawer;
ImageView navDrawerBtn;
HashMap<String, List<String>> listDataChild;
List<String> listDataHeader;
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
protected LinearLayout fullLayout;
protected FrameLayout actContent;
#Override
public void setContentView(final int layoutResID) {
fullLayout= (LinearLayout) getLayoutInflater().inflate(R.layout.home, null); // Your base layout here
actContent= (FrameLayout) fullLayout.findViewById(R.id.content_frame);
getLayoutInflater().inflate(layoutResID, actContent, true); // Setting the content of layout your provided to the act_content frame
super.setContentView(fullLayout);
// here you can get your drawer buttons and define how they should behave and what must they do, so you won't be needing to repeat it in every activity class
prepareListData();
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
navDrawerBtn = (ImageView)findViewById(R.id.headerDrawer);
expListView = (ExpandableListView) findViewById(R.id.lvExp);
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
expListView.setIndicatorBounds(402,465);
} else {
expListView.setIndicatorBoundsRelative(402,465);
}
drawer = (DrawerLayout)findViewById(R.id.drawer_layout);
navDrawerBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(!drawer.isDrawerOpen(expListView)) {
drawer.openDrawer(expListView);
} else {
drawer.closeDrawer(expListView);
}
}
});
//listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
// setting list adapter
expListView.setAdapter(listAdapter);
// Listview Group click listener
expListView.setOnGroupClickListener(new OnGroupClickListener() {
#Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// Toast.makeText(getApplicationContext(),
// "Group Clicked " + listDataHeader.get(groupPosition),
// Toast.LENGTH_SHORT).show();
return false;
}
});
// Listview Group expanded listener
expListView.setOnGroupExpandListener(new OnGroupExpandListener() {
#Override
public void onGroupExpand(int groupPosition) {
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition) + " Expanded",
Toast.LENGTH_SHORT).show();
}
});
// Listview Group collasped listener
expListView.setOnGroupCollapseListener(new OnGroupCollapseListener() {
#Override
public void onGroupCollapse(int groupPosition) {
Toast.makeText(getApplicationContext(),
listDataHeader.get(groupPosition) + " Collapsed",
Toast.LENGTH_SHORT).show();
}
});
// Listview on child click listener
expListView.setOnChildClickListener(new OnChildClickListener() {
#Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
switch (childPosition) {
case 0:
Intent a = new Intent(getApplicationContext(), MainActivity.class);
startActivity(a);
break;
case 1:
Intent b = new Intent(getApplicationContext(), ScheduleActivity.class);
startActivity(b);
break;
}
return false;
// TODO Auto-generated method stub
}
});
}
/*
* Preparing the list data
*/
protected void prepareListData() {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
// Adding child data
listDataHeader.add("VRP Medical Bay");
//listDataHeader.add("");
//listDataHeader.add("");
// Adding child data
List<String> listUnderVRP = new ArrayList<String>();
listUnderVRP.add("eDataClinical");
listUnderVRP.add("Schedule");
listUnderVRP.add("Dictate");
listUnderVRP.add("View Messages");
listUnderVRP.add("Reports for Signature");
listUnderVRP.add("View Billing");
listUnderVRP.add("View State");
listDataChild.put(listDataHeader.get(0), listUnderVRP); // Header, Child data
//listDataChild.put(listDataHeader.get(1), nowShowing);
//listDataChild.put(listDataHeader.get(2), comingSoon);
}
}
my home layout
<?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" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="73dp"
android:background="#color/actionbar" >
<ImageView
android:id="#+id/headerDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_drawer"
android:contentDescription="#string/desc" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/actionHeaderText"
android:layout_toRightOf="#+id/headerDrawer"
android:src="#drawable/e_icon"
android:contentDescription="#string/desc" />
<TextView
android:id="#+id/actionHeaderText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/actionbar_title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="32sp"
android:textStyle="bold"
android:typeface="monospace" />
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ExpandableListView
android:id="#+id/lvExp"
android:layout_width="470dp"
android:layout_height="match_parent"
android:groupIndicator="#drawable/group_selector"
android:transcriptMode="alwaysScroll"
android:layout_gravity="start"
android:childDivider="#4abcd7"
android:divider="#626262"
android:dividerHeight="4dp"
android:cacheColorHint="#fff" >
</ExpandableListView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
My Billing Activity:
public class ViewBillingActivity extends BaseActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_billing_test);
}
my billing layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="73dp"
android:background="#color/actionbar" >
<ImageView
android:id="#+id/headerDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="#string/desc"
android:src="#drawable/ic_drawer" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/actionHeaderText"
android:layout_toRightOf="#+id/headerDrawer"
android:src="#drawable/e_icon" />
<TextView
android:id="#+id/actionHeaderText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/view_billing"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="32sp"
android:textStyle="bold"
android:typeface="monospace" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="90dp"
android:background="#color/view_billing_bg"
android:paddingTop="10dp" >
<TextView
android:id="#+id/latestBillingTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="#string/latest_billing"
android:textColor="#color/white"
android:textSize="34sp"
android:textStyle="normal" />
<TextView
android:id="#+id/latestBillingDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/latestBillingTitle"
android:layout_centerHorizontal="true"
android:text="(03/01/2014 - 03/31/2014)"
android:textColor="#color/white"
android:textSize="24sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="720dp"
android:layout_height="820dp"
android:layout_below="#+id/relativeLayout1"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:background="#color/white"
android:paddingBottom="50dp" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:background="#color/white" >
<RelativeLayout
android:id="#+id/relativeLayout7"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#color/view_mssgs_id_bg" >
<TextView
android:id="#+id/vbTxtID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:gravity="center_horizontal"
android:text="024"
android:textColor="#color/white"
android:textSize="24sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="500dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dp"
android:layout_toRightOf="#+id/relativeLayout7"
android:background="#color/tile_box" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="#string/vb_outstanding_balance"
android:textColor="#color/white"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/vbTxTOutBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView1"
android:layout_alignBottom="#+id/textView1"
android:layout_marginLeft="23dp"
android:layout_toRightOf="#+id/textView1"
android:text="0.00"
android:textColor="#color/white"
android:textSize="24sp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout3"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout2"
android:layout_marginTop="4dp"
android:background="#color/tile_box" >
<TextView
android:id="#+id/vbTxtLastMonthBill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="23dp"
android:layout_toRightOf="#+id/textView1"
android:text="2004.50"
android:textColor="#color/white"
android:textSize="24sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/vbTxtLastMonthBill"
android:layout_alignBottom="#+id/vbTxtLastMonthBill"
android:layout_alignParentLeft="true"
android:layout_marginLeft="11dp"
android:text="#string/vb_last_month_bill"
android:textColor="#color/white"
android:textSize="24sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout4"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout3"
android:layout_marginTop="4dp"
android:background="#color/tile_box" >
<TextView
android:id="#+id/vbTxtPaymentReceived"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="23dp"
android:layout_toRightOf="#+id/textView1"
android:text="2004.50"
android:textColor="#color/white"
android:textSize="24sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/vbTxtPaymentReceived"
android:layout_alignBottom="#+id/vbTxtPaymentReceived"
android:layout_alignParentLeft="true"
android:layout_marginLeft="11dp"
android:text="#string/vb_payments_received"
android:textColor="#color/white"
android:textSize="24sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout5"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout4"
android:layout_marginTop="4dp"
android:background="#color/tile_box" >
<TextView
android:id="#+id/vbTxtPaymentReceivedDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="23dp"
android:layout_toRightOf="#+id/textView1"
android:text="04/05/2014"
android:textColor="#color/white"
android:textSize="24sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/vbTxtPaymentReceivedDate"
android:layout_alignBottom="#+id/vbTxtPaymentReceivedDate"
android:layout_alignParentLeft="true"
android:layout_marginLeft="11dp"
android:text="#string/vb_payment_received_date"
android:textColor="#color/white"
android:textSize="24sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout6"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout5"
android:layout_marginTop="4dp"
android:background="#color/tile_box" >
<TextView
android:id="#+id/vbTxtBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="23dp"
android:layout_toRightOf="#+id/textView1"
android:text="1575.75"
android:textColor="#color/white"
android:textSize="24sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/vbTxtBalance"
android:layout_alignBottom="#+id/vbTxtBalance"
android:layout_alignParentLeft="true"
android:layout_marginLeft="11dp"
android:text="#string/vb_balance"
android:textColor="#color/white"
android:textSize="24sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
First of all, according to design guidelines, it is better to set header text within the ActionBar when navigation drawer is open rather than having separate TextView header within navigation drawer layout.
But in case you really-really need separate "header" text within your navigation drawer - layout (and the way you interact with it) for your navigation drawer is exactly the same as any other regular layout you usually have in your activities. Just declare TextView, give it some reasonable id, get this text view in your activity (findViewById()) and set proper text
Write Change Text Code in onDrawerClosed and onDrawerOpened methods according to the text you want to display..

Categories

Resources