「無法使用」,因爲它非常滯後,幾乎無法獲取所有項目,因爲它速度很慢。對於我在執行導航抽屜時出現的問題,我真的感到很茫然。我正在使用AppCompat v7的材質主題,並使用視圖模式。抽屜只包含600x232的圖像,每個圖像大小約35kb(本地存儲在應用程序中)。我有G3用戶抱怨我的導航抽屜無法使用
下面是從我的MainActivity樣本
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
. . .
mColorIcons = getResources().getStringArray(R.array.color_icons);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
adapter = new MyPerformanceArrayAdapter(this, mColorIcons);
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerList.setAdapter(adapter);
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mDrawerList.setCacheColorHint(Color.TRANSPARENT); // not sure if this is required for you.
mDrawerList.setFastScrollEnabled(true);
mDrawerList.setScrollingCacheEnabled(false);
. . .
這裏是MyPerformanceArrayAdaptor樣子
public class MyPerformanceArrayAdapter extends ArrayAdapter<String>{
private final Activity context;
private final String[] names;
static class ViewHolder {
public ImageView image;
}
public MyPerformanceArrayAdapter(Activity context, String[] names) {
super(context, R.layout.drawer_list_item, names);
this.context = context;
this.names = names;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
// reuse views
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.drawer_list_item, null);
// configure view holder
ViewHolder viewHolder = new ViewHolder();
viewHolder.image = (ImageView) rowView
.findViewById(R.id.image);
rowView.setTag(viewHolder);
}
// fill data
ViewHolder holder = (ViewHolder) rowView.getTag();
String s = names[position];
holder.image.setImageResource(context.getResources().getIdentifier(s, "drawable", context.getPackageName()));
return rowView;
}
}
我將不勝感激,關於如何提高這任何輸入。在測試2013款Moto X(4.4.4),Nexus 5(L)和Nexus 7(L)(2013)時,我沒有任何問題。我想不出與LG G3具體相關的問題。有一些報道稱它在HTC M8上表現不佳。
編輯:這是我的drawer_list_item XML代碼
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"/>
</LinearLayout>
「無法使用」是什麼意思? 「表現不佳」是什麼意思?您是否使用過Apkudo這樣的服務來查看您的應用在各種設備上的外觀? – CommonsWare 2014-10-26 22:25:38
「無法使用」,因爲它極其滯後,並且由於速度有限而幾乎無法獲得所有項目。 – jxn 2014-10-26 22:26:54