Open ghost opened 9 years ago
Hi, I try to add a custom XML, with android 4 and samsung tab there is no problem, nexus 5 with android 5.1.1 I get this error:
Inflation setting LayoutParams width to MATCH_PARENT - does not make much sense as the view might change orientation. Falling back to WRAP_CONTENT
this is my MXL:
<?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" android:background="#ffffa200"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button7" android:layout_gravity="center_horizontal" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="New Text" android:id="@+id/textView" android:gravity="center" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:id="@+id/relative_layout"> <Button android:layout_width="match_parent" android:layout_height="40dp" android:text="DOWNLOAD" android:id="@+id/btn_download" android:layout_centerInParent="true" /> <Switch android:layout_width="40dp" android:layout_height="20dp" android:text="New Switch" android:id="@+id/switch1" android:layout_centerInParent="true" android:visibility="invisible" /> </RelativeLayout> <ImageView android:layout_width="match_parent" android:layout_height="20dp" android:id="@+id/imageView5" android:layout_gravity="center_horizontal" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Shop" android:id="@+id/button9" android:layout_gravity="center_horizontal" /> </LinearLayout>
and this is the adapter:
public class CollectionSelectProductsAdapter extends ArrayAdapter<Page> { private OnDownloadPress mDownloadListener; // View lookup cache private static class ViewHolder { TextView name; Button btn_downlad; } public CollectionSelectProductsAdapter(Context context, ArrayList<Page> users) { super(context, R.layout.collection_select_product, users); } @Override public View getView(int position, View convertView, ViewGroup parent) { final Page page = getItem(position); ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.collection_select_product, parent, false); viewHolder.name = (TextView) convertView.findViewById(R.id.textView); viewHolder.btn_downlad = (Button) convertView.findViewById(R.id.btn_download); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.name.setText(page.name); viewHolder.btn_downlad.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDownloadListener.onButtonPress(page); } }); return convertView; } public interface OnDownloadPress { void onButtonPress(Page page); } public void setListener (OnDownloadPress listener) { mDownloadListener = listener; } }
Hi, I try to add a custom XML, with android 4 and samsung tab there is no problem, nexus 5 with android 5.1.1 I get this error:
Inflation setting LayoutParams width to MATCH_PARENT - does not make much sense as the view might change orientation. Falling back to WRAP_CONTENT
this is my MXL:
and this is the adapter: