Problema with InfoWindowAdapter laytout - android

I implemented one layout to use on popup of map marker (Maps V2), but I cant configure my layout as I need.
In the image bellow, you can see that the popup with informations about the marker have a white border, I need remove it. I neet fill the popup background with yellow (as the center box).
What is wrong in my layout xml?
My XML (info_window_map)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/pastel" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#color/blue_nightsky"
android:orientation="horizontal"
>
<TextView
android:id="#+id/linha_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Linha "
android:textColor="#color/white"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/cod_linha"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:textColor="#color/white"
android:textSize="13sp"
android:layout_gravity="left"
android:layout_marginLeft="5dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/onibus_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ônibus....: "
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/cod_onibus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/previsao_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previsão..: "
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/previsao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
My Adapter (that use the xml)
class MyInfoWindowAdapter implements InfoWindowAdapter{
private final View myContentsView;
MyInfoWindowAdapter(){
myContentsView = getLayoutInflater().inflate(R.layout.info_window_map, null);
}
#Override
public View getInfoContents(Marker marker) {
//Seta a linha no infowindow
TextView txtTitle = ((TextView)myContentsView.findViewById(R.id.cod_linha));
txtTitle.setText(marker.getTitle());
//Pega a informação em snippet e separa linha, codOnibus do endereço
String snippet = marker.getSnippet();
Snippet snp = new Snippet();
snp.fillSnippet(snippet);
TextView txtCodLinha = ((TextView)myContentsView.findViewById(R.id.cod_linha));
txtCodLinha.setText(snp.getLinha());
TextView txtCodOnibus = ((TextView)myContentsView.findViewById(R.id.cod_onibus));
txtCodOnibus.setText(snp.getCodOnibus());
TextView txtPrevisao = ((TextView)myContentsView.findViewById(R.id.previsao));
txtPrevisao.setText(snp.getPrevisao());
return myContentsView;
}
#Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
return null;
}
}

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 :)

How to remove list view item in list view android?

In my application i have one custom list view. whenever i click the close image list item, the list item layout must be removed with space. i used visibility:gone attribute, the list item layout deleted but the space is visible. I am using listview in scroll view ,,that was also not working....please help me out.
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (inflater == null)
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
convertView = inflater.inflate(R.layout.recharge_listitem, null);
TextView accountnumber = (TextView) convertView
.findViewById(R.id.accountnumber);
TextView servicename = (TextView) convertView
.findViewById(R.id.servicetypname);
TextView planamount = (TextView) convertView
.findViewById(R.id.rechargeamount);
final ImageView close = (ImageView) convertView
.findViewById(R.id.crosse_close_img);
final LinearLayout layoutrecharge=(LinearLayout)convertView.findViewById(R.id.rechargelay);
close.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
layoutrecharge.setVisibility(View.GONE);
}
});
accountnumber.setText("Rs."+bpData.get(position).getAccountNumber());
servicename.setText(bpData.get(position).getServicename());
planamount.setText(bpData.get(position).getRechargeamount());
return convertView;
}
}
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/background">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1e365a">
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:text="PAYMENT"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:text="Your Recharges"
android:textColor="#1e365a"
android:textSize="20dp" />
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="4dp"
android:background="#drawable/dottedline_view" />
<ListView
android:id="#+id/recharge_lv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone">
</ListView>
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginTop="12dp"
android:background="#1e365a" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_weight="1"
android:layout_margin="10dp"
android:text="Amount to be Paid"
android:textColor="#1e365a"
android:textSize="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_weight="1"
android:layout_margin="10dp"
android:text="Rs.130"
android:textColor="#1e365a"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="100" >
<EditText
android:id="#+id/ev_b_dob"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="50"
android:hint="Enter coupn code"
android:inputType="text" >
<requestFocus />
</EditText>
<Button
android:id="#+id/bt_apply"
style="#style/payment_button_style"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="-5dp"
android:layout_weight="20"
android:gravity="center"
android:text="Apply" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="28dp"
android:layout_marginRight="30dp">
<CheckBox
android:id="#+id/cb_reload_cash"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pay using Reload Cash"
android:textColor="#1e365a"
android:textSize="20dp"
android:layout_marginLeft="12dp"/>
</LinearLayout>
<Button
android:id="#+id/atmdebit_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="28dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:background="#F93249"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="ATM/DEBIT/CREDIT"
android:textColor="#ffffff"
android:textSize="20dp"/>
<Button
android:id="#+id/netbankng_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="28dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:background="#F93249"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="NET BANKING"
android:textColor="#ffffff"
android:textSize="20dp"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
please help me.
custom listview item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/rechargelay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/accountnumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8008505106" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="(" />
<TextView
android:id="#+id/servicetypname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vodafone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=")" />
</LinearLayout>
<TextView
android:id="#+id/rechargeamount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RS.30"
android:layout_weight="1" />
<ImageView
android:id="#+id/crosse_close_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/close"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Set View.GONE for View is not right way to remove row from ListView. to remove row remove select row item from Adapter data-source and call notify data change method of adapter to populate changes:
close.setTag(position);
close.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int deletePos=Integer.parseInt(v.getTag().toString());
bpData.remove(deletePos);
notifyDataSetChanged();
}
});
Set visibility View.GONE of SCROLL VIEW or other parent of list view....

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:

Error in Android 2.x with the infowindow background

This is my problem in all info window I have are too big, and I like to set up at 180dpheight and 300dp width, or warp_content instead:
I realized that the problem only occurs in version 2.2 and Android 2.3, on Android 4.1 dont have problems, and I do not try on version 3.x
Any idea how to fix it?
I read other post that said changed the getInfoContent for getInfoWindow, but I already have that way.
InfoWindow.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:background="#243439"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imagen"
android:layout_width="114dp"
android:layout_weight="0.5"
android:layout_height="174dp"
android:contentDescription="#string/app_name"/>
<LinearLayout
android:layout_width="174dp"
android:layout_height="174dp"
android:orientation="vertical" >
<TextView
android:id="#+id/titulo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="#FFFFFF"
android:gravity="center_horizontal|center"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/direccion"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:textColor="#FFFFFF"
android:gravity="center_horizontal|center"
android:textSize="12sp" />
<TextView
android:id="#+id/vermas"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textColor="#FFFFFF"
android:gravity="bottom|center_horizontal"
android:text="#string/vermas"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
The fragment.java:
googlemap.setInfoWindowAdapter(new InfoWindowAdapter() {
#Override
public View getInfoWindow(Marker marker) {
View v = getLayoutInflater(null).inflate(R.layout.infowindow, null);
TextView titulo = (TextView) v.findViewById(R.id.titulo);
TextView direccion = (TextView) v.findViewById(R.id.direccion);
ImageView imagen = ((ImageView)v.findViewById(R.id.imagen));
titulo.setText(marker.getTitle());
direccion.setText(marker.getSnippet());
if(hash.get(marker) != null)
imagen.setImageDrawable(getResources().getDrawable(hash.get(marker)));
return v;
}
//..
#Override
public View getInfoContents(Marker marker) {
// TODO Auto-generated method stub
return null;
}
});
}
try below coxmk
<?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:background="#243439"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imagen"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="0.5"
android:contentDescription="#string/app_name" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/titulo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center_horizontal|center"
android:textColor="#FFFFFF"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/direccion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:gravity="center_horizontal|center"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<TextView
android:id="#+id/vermas"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom|center_horizontal"
android:text="test"
android:textColor="#FFFFFF"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>

Set width of custom InfoWindow in Google Maps api v2

I created markers on the map. When I click on them, the custom info windows are always as wide as the screen.
I tried setting layout_width="200dp" but that didn't help. I also tried setting
view.setLayoutParams(new LayoutParams(GetDipsFromPixel(200), GetDipsFromPixel(300)));
I can set the width of the textviews by setting snippetUi.setWidth(GetDipsFromPixel(200)); but the layout still remains screen wide.
<?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:orientation="vertical"
android:background="#FFFFFF"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:padding="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:gravity="center_vertical">
<ImageView
android:id="#+id/worldmap_infowindow_profileimg"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/noimage" />
<TextView
android:id="#+id/worldmap_infowindow_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To do No.2."
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold"
android:paddingLeft="5dp"/>
</LinearLayout>
<View android:id="#+id/separator"
android:background="#ababab"
android:layout_width = "fill_parent"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_height="1dp"/>
<TextView
android:id="#+id/worldmap_infowindow_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="See the Giza Pyramids"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/worldmap_infowindow_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="It was fascinating! It's a shame that it was raining, though."
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="normal" />
</LinearLayout>
Class:
private class CustomInfoWindowAdapter implements InfoWindowAdapter {
private View view;
public CustomInfoWindowAdapter() {
view = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
}
#Override
public View getInfoContents(Marker marker) {
if (WorldMap.this.myMarker != null
&& WorldMap.this.myMarker.isInfoWindowShown()) {
WorldMap.this.myMarker.hideInfoWindow();
WorldMap.this.myMarker.showInfoWindow();
}
return null;
}
#Override
public View getInfoWindow(final Marker marker) {
WorldMap.this.myMarker = marker;
final String title = marker.getTitle();
final TextView titleUi = ((TextView) view.findViewById(R.id.worldmap_infowindow_name));
if (title != null) {
titleUi.setText(title);
} else {
titleUi.setText("");
}
final String snippet = marker.getSnippet();
final TextView snippetUi = ((TextView) view.findViewById(R.id.worldmap_infowindow_details));
if (snippet != null) {
snippetUi.setText(snippet);
} else {
snippetUi.setText("");
}
return view;
}
}
Basically you just need to have another level of layout below root, like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:background="#android:color/transparent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="250dp"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="horizontal">
...
Just create the parent layout with "wrap_content" and a child layout with the desired size:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- This layout defines the desired size -->
<LinearLayout
android:layout_width="240dp"
android:layout_height="320dp"
android:orientation="vertical">
<!-- Your views here -->
</LinearLayout>
</LinearLayout>
If you want to show custom window with fixed size ( Height or Width ) then you have to make drawable and set it as a background of XML.
I have posted my answer HERE with solution.You can refer how it works.
#Override
public View getInfoWindow(Marker arg0) {
return null;
}
#Override
public View getInfoContents(Marker arg0) {
View v = getActivity().getLayoutInflater().inflate(R.layout.custom_info_window, null);
v.setLayoutParams(new LinearLayout.LayoutParams(500,300));
}
In my case, I set the fixed width of one of the child of the layout and it worked. Don't know why it did not work when setting width of the root view. Here is an example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical"
android:padding="3dp">
<ImageView
android:id="#+id/info_window_image"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/facebook"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:text="Free for All Soccer Game"
android:textColor="#color/blue"
android:textSize="#dimen/medium" />
</LinearLayout
>

Categories

Resources