これがAndroidのバージョンや画面サイズの違いによる問題なのかどうかはわかりませんが、予期しない動作が発生しています。
MultiAutoCompleteTextView
オンになっているオンのドロップダウンのUIをテストしており、オンにNexus S
なっているオンAndroid v4.1.2
でテストしてNexus 4
いAndroid v4.2.1
ます。
テキストを入力し始めると、MultiAutoCompleteTextView
いくつかの結果が返されます。ImageView
の左側にを含むカスタムビューを作成しましたTextView
。行が最初に表示されるとき、はImageView
特定の高さと幅を持ちます(左の画像)。
ただし、結果のリストをスクロールして元の行に戻ると、2つのことが起こります。ImageView
同じ寸法のままであるか、の寸法ImageView
が変更されます(右の画像)。
この特定の動作と提供されているスクリーンショットは、で起こっていることですが、Nexus 4
この問題をで再現することはできませんNexus S
。
開発者トレーニングで行われているのと同じように、大きなビットマップを効率的にロードしBitmaps
ています。 ImageViews
連絡先行のレイアウトリソースは次のとおりです。
contact_entry2.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="fill_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/contactPic"
android:layout_width="wrap_content"
vandroid:layout_height="fill_parent"
android:contentDescription="@string/contact_pic_desc"
android:focusable="false"
android:focusableInTouchMode="false"
android:src="@drawable/ic_contact_picture" />
<CheckedTextView
android:id="@+id/contactInfo"
style="@style/CheckedTextViewStyle" >
</CheckedTextView>
</LinearLayout>
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CheckedTextViewStyle">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:textColor">@color/black</item>
<item name="android:background">@color/white</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingLeft">10dp</item>
</style>
</resources>
また、RecipientsCursorAdapterは、SimpleCursorAdapter
(BaseContactsAdapter extends SimpleCursorAdapter
)の孫クラスです。
RecipientsCursorAdapter
package com.sendit.adapters;
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckedTextView;
import android.widget.ImageView;
import com.sendit.Contact;
import com.sendit.R;
import com.sendit.util.ContactsUtils;
import com.sendit.util.ImageFetcher;
public class RecipientsCursorAdapter extends BaseContactsAdapter {
private final String DEBUG_TAG = getClass().getSimpleName().toString();
private Cursor mCursor;
private ImageFetcher mImageFetcher;
public RecipientsCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to, Activity a, int flags, ImageFetcher imageFetcher) {
super(context, layout, c, from, to, a, flags);
mImageFetcher = imageFetcher;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.contact_entry2, null);
// Creates a ViewHolder and store references to the children views
// we want to bind data to.
holder = new ViewHolder();
holder.contactInfo = (CheckedTextView) convertView
.findViewById(R.id.contactInfo);
holder.contactPic = (ImageView) convertView
.findViewById(R.id.contactPic);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
holder.position = position;
mCursor = getCursor();
mCursor.moveToPosition(position);
int contactId = mCursor.getInt(mCursor
.getColumnIndex(ContactsContract.Contacts._ID));
if (mContactCache.get(contactId) == null) {
String name = mCursor.getString(mCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String number = ContactsUtils.getPhoneNumber(mContext, contactId);
mContactCache.put(contactId, new Contact(name, number));
}
Contact c = mContactCache.get(contactId);
CharSequence contactInfo = getContactInfoSpan(c.getName(), c.getPhoneNumber());
holder.contactInfo.setText(contactInfo);
mImageFetcher.loadImage(contactId, holder.contactPic);
return convertView;
}
}
誰かが私を何を調べるべきかに関して正しい方向に向けることができますか?これは画面解像度の問題ですか、それとも最新バージョンのAndroidは以前のバージョンとは異なる方法でこの状況を処理しますか?