add blink to customized listview Item? - android

i have created a listview contains multiple items, and i added a border to those items so it would look like this:
because of this customized border the original blink of an item get blocked so it doesn't appear, and i've tried to add a blink through animation but there is too much delay and too much work on the main thread, i also used animation inside threads but it is the same with the delay thing, which force me to forget about animation so is there anyway that i can make the item blink when its clicked without using animation or with using it but in an efficient way and by the way i used blink animation inside my onItemClickListener you can find it in the code below:
onItemClickListener that handle the blink:
dataList.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, final View arg1,
final int arg2, long arg3) {
// TODO Auto-generated method stub
tvWarningNoEmp.setVisibility(View.GONE);
// adding blink
final Animation animation = new AlphaAnimation(
1, 0); // Change
// alpha
// from
// fully
// visible
// to
// invisible
animation.setDuration(100); // duration - half a
// second
animation
.setInterpolator(new LinearInterpolator()); // do
// not
// alter
// animation
// rate
animation.setRepeatCount(Animation.INFINITE); // Repeat
// animation
// infinitely
animation.setRepeatMode(Animation.REVERSE);
arg1.startAnimation(animation);
// blink one time timer
new CountDownTimer(100, 100) {// CountDownTimer(edittext1.getText()+edittext2.getText())
// also parse it to long
public void onTick(long millisUntilFinished) {
// here you can have your logic to set text to
// edittext
}
public void onFinish() {
arg1.clearAnimation();
}
}.start();
// set margins for tickets buttons
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, 30, 0);
bAssign.setLayoutParams(params);
LinearLayout.LayoutParams paramsO = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
paramsO.setMargins(110, 0, 0, 0);
bEmpChat.setLayoutParams(paramsO);
noEmpLayout.setVisibility(LinearLayout.GONE);
empLayout.setVisibility(LinearLayout.VISIBLE);
Employee item = adapter.getItem(arg2);
ivEmpIcon.setBackgroundResource(R.drawable.free);
tvEmpName.setText(" " + item.getEmpName());
tvEmpDetails.setText(" " + item.getEmpDetails());
empLongitude = item.getEmpLongitude();
empLatitude = item.getEmpLatitude();
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(empLatitude, empLongitude))
.zoom(15).build();
googleEmpMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition));
MarkerOptions marker = new MarkerOptions().position(
new LatLng(empLatitude, empLongitude)).title(
tvEmpName.getText().toString());
marker.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED));
googleEmpMap.addMarker(marker);
// based on item add info to intent
// hide button directions
bEmpDirections.setVisibility(View.GONE);
// current address
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(getApplicationContext(), Locale
.getDefault());
try {
addresses = geocoder.getFromLocation(empLatitude,
empLongitude, 1);
String street = addresses.get(0).getAddressLine(0);
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
tvEmpCurrentAdd.setText(" " + country + "-" + state
+ "-" + street + " st.");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();}
}
});
ListView 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:background="#drawable/redborder" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/btnBack"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:background="#drawable/back" />
<TextView
android:id="#+id/tvWarningNoEmp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="choose an employee from here to assign this problem to!"
android:textColor="#FF0000"
android:layout_marginLeft="400dp"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:background="#drawable/pepsiborder"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:id="#+id/TicketIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:layout_weight="0.1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.7"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/ticketCat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="7dp"
android:gravity="center_vertical"
android:textColor="#D3D9FF"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
<fragment
android:id="#+id/ticketMap"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="State:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ticket No:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Report Date:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketReportDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/ticketDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/llBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:layout_marginTop="170dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="#+id/btnTicketDirections"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#drawable/directions" />
<Button
android:id="#+id/btnSolve"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#drawable/solve" />
<Button
android:id="#+id/btnOther"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:background="#drawable/other" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:background="#drawable/pepsiborder"
android:orientation="vertical" >
<TextView
android:id="#+id/textView124"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#D3D9FF"
android:text="Free Employees"
android:textSize="30sp"
android:gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="20dp"
>
<ListView
android:id="#+id/listTic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_marginTop="20dp"
android:divider="#android:color/transparent"
android:dividerHeight="10dp" >
</ListView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:id="#+id/noempLayout"
android:background="#android:color/transparent"
android:orientation="vertical" >
<TextView
android:text="Please select free Employee to handle this problem!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginTop="300dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="2"
android:id="#+id/empLayout"
android:background="#drawable/pepsiborder"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<ImageView
android:id="#+id/empIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:layout_weight="0.1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.7"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/empName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="7dp"
android:gravity="center_vertical"
android:textColor="#D3D9FF"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
<fragment
android:id="#+id/empMap"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Current Address:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/empAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#D3D9FF" />
<TextView
android:id="#+id/empDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#D3D9FF" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llBtn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginTop="220dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/blueborder"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="#+id/btnEmpDirections"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="center"
android:background="#drawable/directions" />
<Button
android:id="#+id/btnEmpChat"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="center"
android:background="#drawable/chat" />
<Button
android:id="#+id/btnEmpAssign"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="center"
android:background="#drawable/assign" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
ListView Item Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="280dp"
android:layout_height="90dp"
android:orientation="horizontal"
android:background="#drawable/border"
android:layout_marginTop="10dp"
android:padding="10dp"
>
<ImageView
android:id="#+id/imgIcon"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_weight="0.1"
android:gravity="center_vertical"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="0.7"
android:gravity="center_vertical"
>
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="17sp"
android:textColor="#D3D9FF"
android:layout_gravity="center_vertical"
android:layout_marginLeft="7dp"
/>
<TextView
android:id="#+id/txtTitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:textSize="13sp"
android:textColor="#D3D9FF"
android:layout_marginLeft="7dp"
/>
</LinearLayout>
</LinearLayout>
Border.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<stroke
android:width="2dip"
android:color="#8D8D8D" />
<corners android:radius="10dip"/>
<solid android:color="#464A4F" />
</shape>
any help is truly appreciated.

If you want a view to blink:
public void blink(final View v) {
v.setBackgroundColor(Color.DKGRAY);
v.animate().setDuration(25).alpha(0).withEndAction(new Runnable() {
#Override
public void run() {
v.setBackgroundResource(R.drawable.standard_key_normal);
v.setAlpha(1);
}
});
}
Send your View to this function, replace the background with whatever drawable or color resource you want. If you want multiple blinks put it in a for loop.

well i figure out how to reduce the delay and add blink effect without using animation and some how it worked for me and there is no more delay, what i did is I've changed the list's linear layouts to relative and that reduced the amount of nested layouts significantly then i added this method:
private void blink(final View v){
final Handler handler = new Handler();
new Thread(new Runnable() {
#Override
public void run() {
int timeToBlink = 1000; //in milissegunds
try{Thread.sleep(timeToBlink);}catch (Exception e) {}
handler.post(new Runnable() {
#Override
public void run() {
if(v == View.VISIBLE){
v.setVisibility(View.INVISIBLE);
}else{
v.setVisibility(View.VISIBLE);
}
blink();
}
});
}
}).start();
then i used it inside onItemClickListener() --> blink(arg1);
worked perfectly for me, also getting the current address was taking too much so i used Async so now there is no delay at all:
Async used as an inner class:
private class LongOperation extends AsyncTask<String, Void, String> {
String all;
#Override
protected String doInBackground(String... params) {
// current address
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(getApplicationContext(), Locale
.getDefault());
try {
addresses = geocoder.getFromLocation(empLatitude,
empLongitude, 1);
String street = addresses.get(0).getAddressLine(0);
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
all="" + country + "-" + state
+ "-" + street + " st.";
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();}
return all;
}
#Override
protected void onPostExecute(String result) {
tvEmpCurrentAdd.setText(all);
}
#Override
protected void onPreExecute() {}
#Override
protected void onProgressUpdate(Void... values) {}
}
and then i called it inside onItemClickListener:
new LongOperation().execute();
hope this will help others that had simillar problem.

Related

How to click button inside listview

I know this problem already asked many times but i still can't get effective way for solving this. I try for use ListView with clickable/editable widget and Android : How to set onClick event for Button in List item of ListView as reference but the result is i need click button several time for executing my program. Here my program
LeadActivity.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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".LeadSalesActivity">
<LinearLayout
android:background="#E9ECEB"
android:layout_margin="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/b_menusamping2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="20dp"
android:background="#drawable/menu_button"
android:backgroundTint="#27D01B"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome,"
android:textSize="20sp"
android:textStyle="italic"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/t_username3"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="Rizaldi"
android:textColor="#android:color/black"
android:textSize="25sp"
android:textStyle="bold"
android:fontFamily="#font/action_man_bold"/>
</LinearLayout>
<LinearLayout
android:id="#+id/linear_refresh2"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/white">
<ImageView
android:backgroundTint="#27D01B"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="#drawable/icon_update"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_marginLeft="20dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lead"
android:textColor="#android:color/black"
android:textSize="20sp"/>
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="("
android:textSize="20sp"
android:textColor="#android:color/black"/>
<TextView
android:textStyle="bold"
android:id="#+id/count_lead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100"
android:textColor="#android:color/black"
android:textSize="20sp"/>
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=")"
android:textSize="20sp"
android:textColor="#android:color/black"/>
<Button
android:id="#+id/btn_add"
android:layout_marginRight="20dp"
android:backgroundTint="#android:color/holo_blue_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tambah Lead"
android:textAllCaps="false"/>
</LinearLayout>
<LinearLayout
android:padding="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tanggal"
android:textColor="#android:color/black"
android:textSize="20sp"/>
<TextView
android:layout_marginLeft="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lead"
android:textSize="20sp"
android:textColor="#android:color/black"/>
<TextView
android:layout_marginLeft="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telp"
android:textColor="#android:color/black"
android:textSize="20sp"/>
</LinearLayout>
<ListView
android:id="#+id/listviewlead"
tools:listitem="#layout/c_lead"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="#+id/back6"
android:layout_marginRight="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="back"/>
</LinearLayout>
c_lead.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/t_tgl"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Tgl"
android:textSize="15sp"
android:textStyle="italic"
android:textColor="#000000" />
<TextView
android:id="#+id/t_lead4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Lead"
android:textSize="15sp"
android:textColor="#000000" />
<TextView
android:id="#+id/t_numberphone"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:gravity="right"
android:text="No.Telp"
android:textSize="15sp"
android:textColor="#android:color/black"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:id="#+id/btn_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/kotak_abu"
android:layout_marginTop="5dp">
<ImageButton
android:layout_margin="10dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/pencil_icon"/>
</LinearLayout>
<LinearLayout
android:id="#+id/btn_delete"
android:layout_marginLeft="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/kotak_abu"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp">
<ImageButton
android:layout_margin="10dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/delete_icon"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/t_alamat"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="Alamat"
android:textColor="#android:color/black"
android:textSize="15sp"
android:layout_marginLeft="20dp"/>
</LinearLayout>
MyAdapter
public View getView(final int _position, View _v, ViewGroup _container) {
LayoutInflater _inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View _view = _v;
if (_view == null) {
_view = _inflater.inflate(R.layout.c_lead, null);
}
final HashMap<String, Object> hashMap = _data.get(_position);
final TextView t_tanggal = (TextView) _view.findViewById(R.id.t_tgl);
final TextView t_lead = (TextView) _view.findViewById(R.id.t_lead4);
final TextView t_alamat = (TextView) _view.findViewById(R.id.t_alamat);
final TextView t_numberphone = (TextView) _view.findViewById(R.id.t_numberphone);
final LinearLayout btn_edit = (LinearLayout) _view.findViewById(R.id.btn_edit);
final LinearLayout btn_delete = (LinearLayout) _view.findViewById(R.id.btn_delete);
String dateString = _data.get(_position).get("create_date").toString().replace("-","");
SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMddHHmm");
format1.setTimeZone(TimeZone.getTimeZone("GMT+7"));
SimpleDateFormat format2 = new SimpleDateFormat("dd-MM-yyyy");
try {
Date date = format1.parse(dateString);
String dateFinal = format2.format(date);
t_tanggal.setText(String.valueOf((long)(_position + 1)).concat(".").concat(dateFinal));
} catch (ParseException e) {
e.printStackTrace();
}
t_lead.setText(_data.get((int)_position).get("type").toString());
t_alamat.setText(_data.get((int)_position).get("street").toString());
if (_data.get((int)_position).get("mobile").toString().equals(true)){
t_numberphone.setText("Tanpa Nomor");
} else {
t_numberphone.setText(_data.get((int)_position).get("phone").toString());
}
btn_edit.setFocusable(false);
btn_edit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
i.setClass(getApplicationContext(), AddLeadSalesActivity.class);
startActivity(i);
}
});
btn_delete.setFocusable(false);
btn_delete.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "Data Tidak Bisa Dihapus", Toast.LENGTH_SHORT).show();
}
});
return _view;
}
Is there any mistake inside my program? How to solve this?

how can i make my alert dialog box in android

I want to make my alert dialog box something like this.This is a popup window where you have to choose and select the category.Its coming when I click any listview item..
But I ended up make it something like this.as i am a newbie so don't know much about designing.kindly help me in this.
my xml layout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#FFFFFF"
android:gravity="start"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/desimage"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="2dp"
android:layout_marginTop="10dp"
android:src="#drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<TextView
android:text="Chicken Pizza Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="21sp"
android:textStyle="bold"
android:id="#+id/h1"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<TextView
android:text="Chicken Pizza Small Combo"
android:layout_width="wrap_content"
android:textSize="16sp"
android:layout_height="wrap_content"
android:textColor="#8c8181"
android:id="#+id/h2"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<Button
android:text="Quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/mybutton"
android:textColor="#ffffff"
android:id="#+id/quant"
android:layout_weight="1" />
<Button
android:text="-"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/incr"
android:textSize="10sp"
android:textColor="#color/colorButton"
android:layout_weight="1" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:layout_weight="1"
android:id="#+id/n1"
/>
<Button
android:text="+"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
android:textColor="#color/colorButton"
android:layout_weight="1" />
android:id="#+id/decr"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<CheckBox
android:text="SL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/sl"
android:textColor="#8c8181"
android:layout_weight="1" />
<CheckBox
android:text="S"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/s"
android:textColor="#8c8181"
android:layout_weight="1" />
<CheckBox
android:text="M"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/m"
android:textColor="#8c8181"
android:layout_weight="1" />
<CheckBox
android:text="l"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/L"
android:textColor="#8c8181"
android:layout_weight="1" />
<CheckBox
android:text="F"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/f"
android:textColor="#8c8181"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#c0c0c0"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner1"
android:background="#drawable/spinner_bg"
android:layout_weight="1" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner2"
android:background="#drawable/spinner_bg"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_weight="1" >
<Button
android:text="Cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/canc"
android:textColor="#ffffff"
android:background="#drawable/mybutton2"
android:layout_weight=".5" />
<Button
android:text="Ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ok"
android:textColor="#ffffff"
android:background="#drawable/mybutton"
android:layout_weight=".5" />
</LinearLayout>
</LinearLayout>
</ScrollView>
here is my SubMenu Activity where if u click an item it will show popup
public class SubMenu extends AppCompatActivity {
JSONObject jsonobject;
JSONArray jsonarray;
ListView listview;
ListViewAdapter adapter;
ProgressDialog mProgressDialog;
ArrayList<HashMap<String, String>> arraylist;
static String RANK = "id";
static String COUNTRY = "name";
static String FLAG = "image";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sub_menu);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
String SelectedId = getIntent().getStringExtra("id");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Get the view from listview_main.xml
// Execute DownloadJSON AsyncTask
new DownloadJSON().execute();
}
// DownloadJSON AsyncTask
private class DownloadJSON extends AsyncTask<Void, Void, Void> implements AdapterView.OnItemClickListener {
// #Override
// protected void onPreExecute() {
// super.onPreExecute();
// Create a progressdialog
// mProgressDialog = new ProgressDialog(SubMenu.this);
// Set progressdialog title
// mProgressDialog.setTitle("Categories of Main categories.....");
// Set progressdialog message
// mProgressDialog.setMessage("Loading...");
// mProgressDialog.setIndeterminate(false);
// Show progressdialog
// mProgressDialog.show();
// }
#Override
protected Void doInBackground(Void... params) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
// Retrieve JSON Objects from the given URL address
jsonarray = JsonFunctions
.getJSONfromURL("http://cloud.granddubai.com/broccoli/menu_typeitem.php?id=" + getIntent().getStringExtra("id"));
try {
// Locate the array name in JSON
// jsonarray = jsonobject.getJSONArray("main_menu_items");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
// map.put("id", jsonobject.getString("id"));
map.put("name", jsonobject.getString("name"));
map.put("image", jsonobject.getString("image"));
// Set the JSON Objects into the array
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(Void args) {
// Locate the listview in listview_main.xml
listview = (ListView) findViewById(R.id.list1);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(SubMenu.this, arraylist);
// Set the adapter to the ListView
listview.setAdapter(adapter);
listview.setOnItemClickListener(this);
// Close the progressdialog
// mProgressDialog.dismiss();
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button)popupView.findViewById(R.id.canc);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
#Override
public void onClick(View v) {
popupWindow.dismiss();
}});
popupWindow.showAsDropDown(view, 3000, -90);
}
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Replace your layout xml file with this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="#+id/desimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/logo" />
<TextView
android:id="#+id/h1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small"
android:textSize="21sp"
android:textStyle="bold" />
<TextView
android:id="#+id/h2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small Combo"
android:textColor="#8c8181"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="#+id/quant"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="3"
android:background="#drawable/mybutton"
android:text="Quantity"
android:textAllCaps="false"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="7"
android:background="#drawable/stroke_button"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="#+id/incr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent"
android:text="-"
android:textColor="#FFA726"
android:textSize="25dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="number"
android:text="5" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent"
android:text="+"
android:textColor="#FFA726"
android:textSize="25dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<CheckBox
android:id="#+id/sl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="SL"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="#+id/s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="S"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="#+id/m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="M"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="#+id/L"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="l"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="#+id/f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="F"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#c0c0c0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="#drawable/stroke_button"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/stroke_button"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<Spinner
android:id="#+id/spinner2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="SPECIAL INSTRUCTIONS"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/stroke_button"
android:padding="#dimen/_10sdp">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:gravity="top"
android:inputType="textCapSentences|textMultiLine"
android:lines="5"
android:maxLines="5"
android:padding="2dp"
android:textColor="#c0c0c0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<Button
android:id="#+id/canc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="#drawable/mybutton2"
android:text="Cancel"
android:textColor="#ffffff" />
<Button
android:id="#+id/ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/mybutton"
android:text="Ok"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</ScrollView>
In your res/drawable add these xml:
mybutton.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="25dp" />
<solid android:color="#004D40" />
</shape>
mybutton2.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="25dp" />
<solid android:color="#FFA726" />
</shape>
stroke_button.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF" />
<corners android:radius="20dp" />
<stroke
android:width="1dp"
android:color="#c0c0c0" />
</shape>
#z.al
1) For set quantity u remove two button instead of two button you simply put two TextView so now you have Total 3 TextView (One for "-" one for "Count" and one for "+"). This Textview have Linear as parent and with the help of Drawable XML u can set Background.
2) And for Spinner you need to implement Custom Spinner
for Proper view give proper padding and margin.
refer link for custom spinner: "http://mrbool.com/how-to-customize-spinner-in-android/28286"

Animation a layout from bottom to top with fade in

I want a animation that first FadeIn the TextView with id Symbol_no from Bottom to Top Then FadeIn other View on the screen.
symbolnotextview.animate().setDuration(duration).
scaleX(1).scaleY(1).
translationX(0).translationY(0).
setInterpolator(sDecelerator).
withEndAction(new Runnable() {
public void run() {
// Animate the description in after the image animation
// is done. Slide and fade the text in from underneath
// the picture.
mTextView.setTranslationY(-mTextView.getHeight());
mTextView.animate().setDuration(duration/2).
translationY(0).alpha(1).
setInterpolator(sDecelerator);
}
});
But i think this is not what i mean to do .
Here is the XML of the design
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100"
android:id="#+id/toplevel">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="15"
android:background="#drawable/borderframe">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="5dp"
android:src="#drawable/abc_btn_radio_to_on_mtrl_015"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="21477"
android:padding="5dp"
android:gravity="center"
android:background="#drawable/border"
android:id="#+id/Symbol_no"
/>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="Rohit Shrestha"
android:layout_weight="20"
android:textSize="30sp"
android:gravity="center"
android:id="#+id/name"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="20"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:id="#+id/parentblock">
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Block"
android:textSize="30sp"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/block_no"
android:background="#drawable/border"/>
<TextView
android:layout_width="120dp"
android:layout_height="fill_parent"
android:text="7"
android:gravity="center"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:textSize="40sp"
android:id="#+id/block_no"
android:background="#drawable/border"/>
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:weightSum="100"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="30dp"
android:id="#+id/class_container"
>
<LinearLayout
android:layout_weight="40"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#drawable/border"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Class"
android:textSize="30dp"
android:gravity="center"
android:id="#+id/class_text"
/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="#+id/room_no"
android:textSize="25dp"
android:gravity="center"
android:text="8"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_weight="40"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#drawable/border"
android:gravity="center"
android:layout_marginLeft="15dp">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Seat"
android:gravity="center"
android:textSize="30dp"
android:id="#+id/Seat_text"
/>
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="8"
android:gravity="center"
android:id="#+id/Seat_No"
android:textSize="25dp"
/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="Good Luck"
android:gravity="center"
android:id="#+id/display_notification"
android:layout_weight="10"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/Time_Left"
android:text="5 hours to go"
android:gravity="center"
android:textSize="20dp"
android:layout_weight="10"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="10dp"
android:text="15 july,2015"
android:gravity="center"
android:layout_weight="10"/>
This is the output :
Try this:
Button btn = (Button)findViewById(R.id.Symbol_no);
DisplayMetrics dis = getResources().getDisplayMetrics();
TranslateAnimation anim = new TranslateAnimation(0, 0, dis.heightPixels, 0);
anim.setDuration(1000);
anim.setAnimationListener(new AnimationListener()
{
#Override
public void onAnimationStart(Animation arg0)
{
}
#Override
public void onAnimationRepeat(Animation arg0)
{
}
#Override
public void onAnimationEnd(Animation arg0)
{
// show whatever you want to show after animation is finished.
}
});
btn.startAnimation(anim);

Cannot add childs to linearLayout

In my app what i want is to dynamically add buttons to a linear layout based on the length of the array.For example if the length of array is 4 then ,4 buttons should be added to the linear layout.I tried doing that but always my app crashes
The linearlayout which is at the bottom of the xml is where i wanna add the buttons
XMl
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/hsjobslogo"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/mrd_home"
android:layout_marginRight="10dp"
android:src="#drawable/home168"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/header"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout2">
<TextView
android:layout_width="0dp"
android:layout_height="33dp"
android:layout_weight="2"
android:layout_marginTop="04dp"
android:text="Resource"
android:gravity="center|start"
android:textColor="#fff"
android:textStyle="bold"
android:layout_marginLeft="10dp"
android:textSize="18sp" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:padding="10dp"
android:visibility="gone"
android:layout_marginTop="-5dp"
android:src="#drawable/edit" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.35"
android:visibility="visible"
android:id="#+id/ll_main_pi"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textStyle="bold"
style="#style/Job_on_Call"
android:textColor="#000"
android:id="#+id/tv_mrd_pi_name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" [ "
style="#style/Job_on_Call"
android:singleLine="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gender"
style="#style/Job_on_Call"
android:textColor="#000"
android:id="#+id/tv_mrd_gender" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=","
style="#style/Job_on_Call"
android:singleLine="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age"
style="#style/Job_on_Call"
android:textColor="#000"
android:id="#+id/tv_mrd_age" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" ]"
style="#style/Job_on_Call"
android:singleLine="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profession"
style="#style/Job_on_Call"
android:textColor="#000"
android:id="#+id/tv_mrd_profession" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" [ "
style="#style/Job_on_Call"
android:singleLine="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yrs"
style="#style/Job_on_Call"
android:textColor="#000"
android:id="#+id/tv_mrd_exp_yrs" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="."
style="#style/Job_on_Call"
android:singleLine="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Months"
style="#style/Job_on_Call"
android:textColor="#000"
android:id="#+id/tv_mrd_exp_months" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" ]"
style="#style/Job_on_Call"
android:singleLine="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
style="#style/Job_on_Call"
android:singleLine="false"
android:layout_marginBottom="2dp"
android:id="#+id/tv_mrd_area" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
style="#style/Job_on_Call"
android:singleLine="false"
android:layout_marginBottom="2dp"
android:id="#+id/tv_mrd_city" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
style="#style/Job_on_Call"
android:singleLine="false"
android:layout_marginBottom="2dp"
android:id="#+id/tv_mrd_state" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
style="#style/Job_on_Call"
android:singleLine="true"
android:id="#+id/tv_mrd_country" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:layout_width="0dp"
android:layout_height="1dp"
android:gravity="bottom"
android:layout_gravity="bottom"
android:background="#drawable/divider_light"
android:layout_weight="0.2" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1.6"
android:layout_height="wrap_content"
android:background="#drawable/rectangle">
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:text="Personal Info"
android:textStyle="bold"
android:textSize="18sp"
android:id="#+id/tv_mrd_header"
style="#style/Job_on_Call"
android:textColor="#fff"
android:layout_marginTop="05dp"
android:layout_marginLeft="19dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/plus_one"
android:visibility="gone"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:id="#+id/iv_mrd_add" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/edit_one"
android:visibility="visible"
android:layout_marginRight="5dp"
android:layout_marginLeft="10dp"
android:id="#+id/iv_mrd_edit" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="5dp"
android:id="#+id/iv_mrd_go_left"
android:src="#drawable/left_arrow" />
<ViewFlipper
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:visibility="visible"
android:id="#+id/mrd_view_flipper"
android:layout_gravity="center_horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="2dp"
android:id="#+id/ll_my_resource_personal_details">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nationality"
android:textStyle="bold"
android:id="#+id/tv_mrd_nationality_header"
android:layout_marginTop="02dp"
style="#style/Job_on_Call"
android:textColor="#000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="2dp"
android:id="#+id/ll_my_resource_refference_details">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textStyle="bold"
android:id="#+id/tv_mrd_ref_name_header"
android:layout_marginTop="02dp"
style="#style/Job_on_Call"
android:textColor="#000" />
</LinearLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Document Type"
android:textStyle="bold"
android:id="#+id/dumm1"
android:layout_marginTop="05dp"
style="#style/Job_on_Call"
android:textColor="#000" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp">
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:id="#+id/mrd_profile_pic"
android:layout_margin="10dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</ViewFlipper>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="5dp"
android:id="#+id/iv_mrd_go_right"
android:src="#drawable/right_arrow" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:layout_gravity="center"
android:gravity="center"
android:id="#+id/add_doc_circles"
android:orientation="horizontal">
The layout where i want to create buttons dynamically
</LinearLayout>
</LinearLayout>
Code
if (NewDataSet.get("Table2") instanceof JSONArray) {
isDocPresent = true;
JSONArray array = NewDataSet.getJSONArray("Table2");
numOfDocCircles = array.length();
LayoutInflater layoutInflater;
Button button = new Button(context);
for (int k = 0; k < array.length(); k++) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(30, 30);
button.setLayoutParams(params);
button.setText("" + k);
llAddDocCircles.addView(button);
}
Error
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Please help me out whats the problem?
Move your button creation into the for loop, in your code you are basically just adding the same Button instance to the parent layout several times:
for (int k = 0; k < array.length(); k++) {
Button button = new Button(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(convertDpToPixel(30), convertDpToPixel(30));
button.setLayoutParams(params);
button.setText("" + k);
llAddDocCircles.addView(button);
}
Use below method to convert dp to pixel.
public static float convertDpToPixel(float dp){
Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
float px = dp * (metrics.densityDpi / 160f);
return px;
}
In your for loop call this method as:
for (int k = 0; k < array.length(); k++) {
llAddDocCircles.addView(addMoreButton("" + k));
}
And your addMoreButton() method is:
public Button addMoreButton(String text) {
Button button = new Button(context);
button.setId(buttonID);
LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
button LayoutParams.setMargins(10, 10, 10, 10); //Add this if you want margin of 10dp
button.setLayoutParams(buttonLayoutParams );
buttonArrayList.add(button);
buttonID++;
return button;
}
And you can easily access these button value by:
private static int buttonID = 0;
private ArrayList<Button> buttonArrayList= new ArrayList<Button>();
// loop to handle each button
for (int i = 0; i < buttonArrayList.size(); i++) {
Button button = buttonArrayList.get(i);
// do your stuff with each button
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
}

What's the difference between listview item and listview footer in rendering life cycle?

I have a listview contains items and footer views. Items layout works as it should, but footer's layout doesn't work like item views...
I could't understand where my fault is.
This is my item's layout xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/lstCardItem"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/pm_dashboard_cardshadow" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5.33dp"
android:layout_marginLeft="11.67dp"
android:layout_marginRight="11.67dp"
android:layout_marginTop="6dp" >
<ImageView
android:id="#+id/ivCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:animateLayoutChanges="true"
android:scaleType="fitXY" />
<com.controls.DynamicResizeImageView
android:id="#+id/ivCardLock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="#drawable/pm_dashboard_cardmask"
android:scaleType="center"
android:src="#drawable/selector_btn_dashboard_lock" />
<LinearLayout
android:id="#+id/llInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:gravity="top|right"
android:orientation="vertical"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:visibility="visible" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|right"
android:gravity="center|right"
android:orientation="horizontal"
android:paddingBottom="4dp"
android:paddingTop="4dp" >
<TextView
android:id="#+id/tvCardBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/tvCurrency"
android:gravity="top"
android:text="10,344"
android:textColor="#color/white"
android:textSize="18dp"
android:typeface="serif" />
<TextView
android:id="#+id/tvCurrency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="3dp"
android:layout_marginTop="2dp"
android:gravity="top"
android:text="#string/global_currency"
android:textColor="#color/white"
android:textSize="10dp"
android:typeface="sans" />
<TextView
android:id="#+id/tvCardBalanceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/pgDashboard_lblBalanceBanner"
android:textColor="#color/white"
android:textSize="11.33dp"
android:typeface="monospace" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/pm_dashboard_seam" />
</LinearLayout>
For my businness side lifecycle:
private void refreshCards() {
if (applyButtons != null)
DashboardFragment.this.lvCards.removeFooterView(applyButtons);
applyButtons = new LinearLayout(getActivity());
applyButtons.setTag("FOOTER");
applyButtons.setOrientation(LinearLayout.VERTICAL);
AbsListView.LayoutParams LLParams = new AbsListView.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
applyButtons.setLayoutParams(LLParams);
if (ininalCount < 32) {
View createNewCardButton = getApplyButtonView(R.string.pgDashboard_lblCreateIninalCard, R.drawable.pm_dashboard_card_yenikartolustur, R.drawable.pm_dashboard_arrow_icon, new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), CreateNewCardActivity.class);
startActivity(intent);
}
});
View AddCard = getApplyButtonView(R.string.pgDashboard_lblAddCard, R.drawable.pm_dashboard_card_yenikartekle, R.drawable.pm_dashboard_plus_icon, new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), AddCardActivity.class);
startActivity(intent);
}
});
applyButtons.addView(createNewCardButton);
applyButtons.addView(AddCard);
}
final View applyIngCard = getApplyButtonView(R.string.pgDashboard_lblApplyToIngCard, R.drawable.pm_dashboard_card_orange, R.drawable.pm_dashboard_arrow_icon, new View.OnClickListener() {
#Override
public void onClick(View v) {
CardApplicationActivity.Synchronizer.synchronize((BaseActivity) getActivity(), new OnSyncCompletedListener() {
#Override
public void onSyncCompleted() {
Intent intent = new Intent(getActivity(), CardApplicationActivity.class);
startActivity(intent);
}
});
}
});
applyButtons.addView(applyIngCard);
View view = new View(getActivity());
view.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics())));
view.setBackgroundResource(getResources().getColor(R.color.transparent));
applyButtons.addView(view);
bindAdapter();
}
private View getApplyButtonView(int stringId, int backgroundId, int iconId, View.OnClickListener onClickListener) {
final View view = inflater.inflate(R.layout.dashboard_list_card_item, null);
return view;
}
public void bindAdapter() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
DashboardFragment.this.lvCards.setLayoutTransition(new LayoutTransition());
DashboardFragment.this.lvCards.addFooterView(applyButtons, null, false);
if (adapter == null) {
adapter = new CardListAdapter(getActivity(), R.layout.dashboard_list_card_item, productModelContainerList);
controller = new CardListController(lvCards);
lvCards.setDropListener(this);
controller.setDragInitMode(CardListController.ON_LONG_PRESS);
lvCards.setFloatViewManager(controller);
lvCards.setOnTouchListener(controller);
lvCards.setAdapter(adapter);
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
DashboardFragment.this.lvCards.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
DashboardFragment.this.lvCards.setLayoutTransition(null);
}
}
Here i made some changes,, use these and let me know... otherwise i need your drawable resources to set this.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/lstCardItem"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#color/background_holo_dark" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5.33dp"
android:layout_marginLeft="11.67dp"
android:layout_marginRight="11.67dp"
android:layout_marginTop="6dp" >
<ImageView
android:id="#+id/ivCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:animateLayoutChanges="true"
android:scaleType="fitXY" />
<ImageView
android:id="#+id/ivCardLock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="#color/background_holo_light"
android:scaleType="center"
android:src="#color/bgColor" />
<LinearLayout
android:id="#+id/llInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cropBG"
android:gravity="top|right"
android:orientation="vertical"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:visibility="visible" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right|center_horizontal"
android:gravity="center|right"
android:orientation="horizontal"
android:paddingBottom="4dp"
android:paddingTop="4dp" >
<TextView
android:id="#+id/tvCardBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/tvCurrency"
android:gravity="top"
android:text="10,344"
android:textColor="#android:color/white"
android:textSize="18dp"
android:typeface="serif" />
<TextView
android:id="#+id/tvCurrency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="3dp"
android:layout_marginTop="2dp"
android:gravity="top"
android:text="Currency"
android:textColor="#android:color/white"
android:textSize="10dp"
android:typeface="sans" />
<TextView
android:id="#+id/tvCardBalanceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="pgDashboard_lblBalanceBanner"
android:textColor="#android:color/white"
android:textSize="11.33dp"
android:typeface="monospace" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bottom_btn_bg_color" />
</LinearLayout>

Categories

Resources