私はSQLiteのデータベースからデータを取得するためにSimpleCursorAdapterを使用して、データベースから2つの文字列を表示するには、カスタムレイアウトとリストビューを使用しています。今私は2つの質問があります:リストビューカスタム・アダプタ
特定の条件に基づいて特定の行に星を表示するにはカスタムアダプターを作成する必要がありますか?私は自分のカスタムレイアウトでイメージを既に非表示に設定していて、行データ自体のいくつかの条件に基づいて可視に設定する必要があります。私はすべてのタブとお気に入りのタブを実装し、すべて正常に動作し、私は星のアイコンが必要でした。レシピの画像を特定の行に配置することも、この問題に直面しています。
リストビューで動的に画像を取得するための最良の方法は何ですか?私は怠惰な画像のチュートリアルに従ってきましたが、私はCustomCursorAdapterを使ってそれを実装する方法を知らなかったので、baseadapterを使って実装されていました。シンプルカーソルチュートリアルでlazyloading画像へのリンクは何ですか?
public class AlternateRowCursorAdapter extends SimpleCursorAdapter{
int layoutn;
Cursor mCursor;
String[] fromn;
int[] ton;
LayoutInflater mInflater;
private int[] colors = new int[] { Color.parseColor("#000000"), Color.parseColor("#303030") };
public AlternateRowCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, R.layout.listtype, c, from, to);
this.mCursor = c;
}
/**
* Display rows in alternating colors
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
ImageView star = (ImageView)view.findViewById(R.id.favoritesicon); // The star I want to show
if (mCursor.getString(8) == "YES") // shows if the item is in favorites
{
star.setVisibility(view.VISIBLE);
}
int colorPos = position % colors.length;
view.setBackgroundColor(colors[colorPos]);
return view;
}
}
イメージは静的であるかのURLから – Khan
画像を取得あなたの答えのために描画可能なフォルダ –