gpt4 book ai didi

android - 如何为此 listView 代码实现 ImageAdapter?

转载 作者:行者123 更新时间:2023-11-29 00:43:02 25 4
gpt4 key购买 nike

ListView 代码如下:

public final static String ITEM_TITLE = "title";   
public final static String ITEM_CAPTION = "caption";
public Resources resources;
public static Uri path;
public static File file;
public static ProgressDialog m_progressDialog;
public static ListView list;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);

// create our list and custom adapter
SeparatedListAdapter adapter = new SeparatedListAdapter(this);
adapter.addSection("Local documents:", new ArrayAdapter<String>(this,
R.layout.list_item, new String[] { "WindowsONE Mobile PK", "WindowsorONE Moldings","Filet for a burger video" }));
adapter.addSection("Non-local resources:", new ArrayAdapter<String>(this,
R.layout.list_item, new String[] { "Launch Photo slideshow link", "Dealer locator link" }));
adapter.addSection("Send emails:", new ArrayAdapter<String>(this,
R.layout.list_item, new String[] { "Send Dealer Locator email", "Send Catalog email","Send install instrucation link" }));
//For extra Information in Listview
//adapter.addSection("Non-local resources:", new SimpleAdapter(this, security, R.layout.list_complex,
//new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption }));
list = getListView();
list.setAdapter(adapter);
list.setTextFilterEnabled(true);
list.setOnItemClickListener(this);
}

}

最佳答案

public class ListContacts extends ListActivity {

ListAdapter lAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


Cursor cursor = getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null,
ContactsContract.Contacts.HAS_PHONE_NUMBER + " = 1", null,
"UPPER(" + ContactsContract.Contacts.DISPLAY_NAME + ") ASC");

startManagingCursor(cursor);


/** start mapping */
String[] columns = new String[] { ContactsContract.Contacts.DISPLAY_NAME };
int[] names = new int[] { R.id.contact_name };
lAdapter = new ImageCursorAdapter(this, R.layout.contact_listview,
cursor, columns, names);
setListAdapter(lAdapter);


}





public class ImageCursorAdapter extends SimpleCursorAdapter

{

public ImageCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);

}

* @param pos
* : the position in the list/cursor,
* @param inView
* : The View object of the row that was last created, null if
* its the first row
* @param parent
* : The ViewGroup object of the parent view return View :
* returns a View object when called
* @see android.widget.CursorAdapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
public View getView(int pos, View inView, ViewGroup parent) {

View v = inView;

}

}

关于android - 如何为此 listView 代码实现 ImageAdapter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8209867/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com