These are my code, I run these code in AsyncTask onPostExcute function.
LayoutInflater inflater =LayoutInflater.from( this.context );
LinearLayout layout = ( LinearLayout) inflater.inflate(R.layout.custom_info_window, null, false);
layout.addView(layout);
View view = (View) layout;
((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);
String title = marker.getTitle();
TextView titleUi = ((TextView) view.findViewById(R.id.title));
titleUi.setText(title);
when the application run to here, no error and responding
here is my xml file named custom_info_window.xml contents
<?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="horizontal" >
<ImageView
android:id="@+id/badge"
android:contentDescription="@string/info_window"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:adjustViewBounds="true" >
</ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:ellipsize="end"
android:singleLine="true"
android:textColor="#ff000000"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="#ff7f7f7f"
android:textSize="14sp" />
</LinearLayout>
I try to dispaly this view as a child view of Mainactivity after AsyncTask executed but it did not work. There is no error or warning. I set breakpoint at the line "titleUi.setText("1312")", when the application run to here, there is no responding. It looks like dead.
anyone can help me? Thank you advance.
Try to post the whole AsyncTask code here. I think the fault is in the below part of your code:
LayoutInflater inflater =LayoutInflater.from( this.context );
LinearLayout layout = ( LinearLayout) inflater.inflate(R.layout.custom_info_window, null, false);
layout.addView(layout);
View view = (View) layout;
Try this instead,
LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.custom_info_window, null);
((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);
String title = marker.getTitle();
TextView titleUi = ((TextView) view.findViewById(R.id.title));
titleUi.setText(title);