开发者

LayoutInflator issue

开发者 https://www.devze.com 2022-12-21 11:18 出处:网络
I\'ve a list view with custom list adapter (list_item.xml). I have multiple layout folder to support multiple screen size. I found out when I inflate using LayoutInflater, it\'s always taking the view

I've a list view with custom list adapter (list_item.xml). I have multiple layout folder to support multiple screen size. I found out when I inflate using LayoutInflater, it's always taking the view from main "layout" folder.

I've a phone with screen size "427x320". Thi开发者_如何转开发s is my code:

private LayoutInflater mInflater;

public ListAdapter(Context context, MenuPage menuPage, Activity activity) {
        // Cache the LayoutInflate to avoid asking for a new one each time.
        mInflater = LayoutInflater.from(context);
}

public View getView(final int position, View convertView, ViewGroup parent) {
        convertView = mInflater.inflate(R.layout.list_item, null);

}

How do I get the layout inflater to pick the list_item.xml from "layout-427x320" folder and not the "layout" folder?


First, Android does not support 427x320 as a screen size. Second, layout-MMMxNNN has been deprecated.

Visit Table 2 here and find out the right values (layout-small, maybe?) that will work for your project.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号