我正在Android片段中开发一个ListView.该类扩展了ListFragment.
我试过这个例子:http: //www.heikkitoivonen.net/blog/2009/02/15/multicolumn-listview-in-android/
但问题是,如果类扩展了ListFragment,则没有定义构造函数SimpleAdapter,将其更改为ListActivity会使SimpleAdapter工作,但是应用程序不会.
这是代码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View tmp_view = inflater.inflate(R.layout.clients_list, container, false);
ListView list = (ListView) tmp_view.findViewById(R.id.list);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("train", "101");
map.put("from", "6:30 AM");
map.put("to", "7:40 AM");
mylist.add(map);
map = new HashMap<String, String>();
map.put("train", "103(x)");
map.put("from", "6:35 AM");
map.put("to", "7:45 AM");
mylist.add(map);
// ...
SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, …Run Code Online (Sandbox Code Playgroud) 我是新的android现在我想从网址显示图像.我在listview中使用imageview.我想将图像列表添加到列表项的每一行.我使用SimpleAdapter,但imageview显示为空白.
这是主要活动:
package com.example.mysqltest;
import java.util.ArrayList;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class ReadComments extends ListActivity {
// Progress Dialog
private ProgressDialog pDialog;
// testing on Emulator:
private static final String READ_COMMENTS_URL = "http://192.168.30.198/test/webservice/comments.php";
// JSON IDS:
private static final String TAG_SUCCESS = "success";
private static final String TAG_TITLE = "title";
private static final String …Run Code Online (Sandbox Code Playgroud) android listview android-listview android-imageview simpleadapter
我正在从网址获取图像.我在listview中使用imageview.我想将位图图像列表添加到列表项的每一行.我使用SimpleAdapter但是imageview显示为空白.我的代码如下!
ArrayList<HashMap<String, Bitmap>> mylist = new ArrayList<HashMap<String, Bitmap>>();
Bundle bundle = this.getIntent().getExtras();
get = bundle.getString("name");
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.propertyhookup.com/mobile/propertylist.php");
nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("zipcode", get.trim()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
//convert response to string
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line …Run Code Online (Sandbox Code Playgroud) 在创建我自己的SimpleAdapter对象之前因为我想要更改行的颜色,我只是使用了新的SimpleAdapter(...).现在我使用自己的自定义SimpleAdapter,行颜色正在改变,但我的文本没有更新.我调用了adapter.notifyDataSetChanged(),但它仍然只显示示例文本 - "TextView".正如我所说,当我没有创建自己的适配器时,一切正常.我怀疑它可能与我正在初始化的命令有关:
public class AddScreen extends Activity implements OnClickListener,
OnItemClickListener, OnItemLongClickListener {
SimpleAdapter adapter;
List<HashMap<String, String>> painItems = new ArrayList<HashMap<String, String>>();
ListView listthings;
int[] to;
String[] from;
public void onCreate(Bundle savedInstanceState) {
...
listthings = (ListView) findViewById(R.id.listthings);
from = new String[] { "row_1", "row_2" };
to = new int[] { R.id.row1, R.id.row2 };
adapter = new Adapter(this, painItems, R.layout.mylistlayout,
from, to);
listthings.setAdapter(adapter);
...
}
public class Adapter extends SimpleAdapter{
HashMap<String, String> map = new HashMap<String, String>();
public Adapter(Context context, …Run Code Online (Sandbox Code Playgroud) 我正在使用一个简单的适配器在列表视图中的不同文本字段中显示字符串集...我想当我点击该列表视图中的特定内容时,某些textview应该是不可见的...如何做...
我的代码是
String[] from = new String[] {"ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN"};
int[] to = new int[] { R.id.textView_1, R.id.textView_2, R.id.textView_3, R.id.textView_4, R.id.textView_5, R.id.textView_6, R.id.textView_7};
Adapter adapter = new SimpleAdapter(this, Maps, R.layout.search, from, to);
ListView lvSearch = (ListView) findViewById(R.id.listView_SearchResult);
lvSearchResult.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
点击这里
R.id.textView_5, R.id.textView_6, R.id.textView_7
Run Code Online (Sandbox Code Playgroud)
应该是看不见的
我正在使用SimpleAdapter填充ListView
ArrayList<Recipe> ciboList = null;
ArrayList<HashMap<String,Object>> data = new ArrayList<HashMap<String,Object>>();
for(int i=0;i<ciboList.size();i++){
// Recipe is my own class defined in another java
Recipe r = (Recipe) ciboList.get(i);
HashMap<String,Object> ricettaMap = new HashMap<String, Object>();
// Informations loaded from Recipe.java
ricettaMap.put("tipo", r.getTipo());
ricettaMap.put("titolo", r.getTitolo());
ricettaMap.put("difficolta", r.getDifficolta());
ricettaMap.put("tempo", r.getTempo());
ricettaMap.put("persone", r.getPersone());
ricettaMap.put("ingredienti", r.getIngredienti());
ricettaMap.put("vino", r.getVino());
ricettaMap.put("consigli", r.getConsigli());
ricettaMap.put("preparazione", r.getPreparazione());
}
}
String[] from = {"tipo", "titolo", "difficolta", "tempo", "ingredienti", "vino", "consigli", "preparazione", "persone"};
int[] to = {R.id.ricettaTipo, R.id.ricettaTitolo, R.id.ricettaDifficolta, R.id.ricettaTempo, R.id.ricettaIngredienti, R.id.ricettaVino, R.id.ricettaConsigli, …Run Code Online (Sandbox Code Playgroud) 我有一个复杂布局的列表R.layout.menu_row.它由一个ProgressBar和一个文本字段组成.我使用的适配器:
SimpleAdapter simpleAdapter = new SimpleAdapter(this, getData(path),
R.layout.menu_row, new String[] { "title", "progress" },
new int[] { R.id.text1,R.id.progressBar1});
Run Code Online (Sandbox Code Playgroud)
适配器知道如何自己处理TextViews但不是ProgressBars,所以我编写了一个复杂的数据绑定器:
SimpleAdapter.ViewBinder viewBinder = new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object data, String textRepresentation) {
//here goes the code
if () {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
现在我被困在函数内填充映射.我需要将string的值设置progress为setProgress方法ProgressBar.但我没有得到字符串progress和句子的句柄ProgressBar.
android android-progressbar simpleadapter android-viewbinder
我试图创建一个应用程序,使用户能够创建事件,然后邀请参与者.因此,当用户进入"添加参与者"页面时,在输入所有信息后,我试图通过使用onResume()直接返回"参与者列表"页面,但是如何更新列表视图?我试图使用notifyDataSetChanged()但不工作.
以下是参与者列表的代码:
public class EventPage extends ListActivity implements OnClickListener {
Intent intent;
TextView friendId;
EventController controller = new EventController(this);
TabHost th;
Button addparticipant;
String eventId;
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.eventpage);
addparticipant = (Button) findViewById(R.id.addpart);
addparticipant.setOnClickListener(this);
// create tabs
th = (TabHost) findViewById(R.id.tabhost);
th.setup();
TabSpec specs = th.newTabSpec("tag1"); // setting up a tabspec in
// tabhost(th) call it tag1
specs.setContent(R.id.tab1);// set content of "tab1" xml
specs.setIndicator("Participants");
th.addTab(specs);
specs = th.newTabSpec("tag2"); // …Run Code Online (Sandbox Code Playgroud) 我使用SimpleAdapter和Listview的自定义行布局
SimpleAdapter adapter = new SimpleAdapter(ListOrder.this, oslist,
R.layout.list_v,
new String[] { "name","time","status" },
new int[] { R.id.tablename, R.id.timeorder, R.id.status});
list.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
之后,我重新加载Listview的数据,我想删除旧数据.在将新数据添加到Listview之前,我不知道如何删除旧数据.
我用了
adapter.remove(adapter.getItem(i));
Run Code Online (Sandbox Code Playgroud)
但有错误
对于SimpleAdapter类型,方法remove(Object)未定义
请帮我 !谢谢!
android listview android-listview android-adapter simpleadapter
我正在尝试从URL使用Universal Image Loader库中检索图像.我得到了一个nullpointer exception.我用a SimpleAdapter来显示Listview Image.我做了以下编码.我是这个图书馆的新手,因此一步一步指导我.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu_items);
i=getIntent();
imageLoader.getInstance();
ListView salad_list=(ListView)findViewById(R.id.salads);
ListAdapter k=new SimpleAdapter(MenuItemsActivity.this,items,R.layout.menulist,new String[]{"Item_Name","Desc","Currency","Price"},new int[]{R.id.cat_name,R.id.textView1,R.id.textView2,R.id.textView3})
{
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final View v = super.getView(position, convertView, parent);
// TextView picpath=(TextView)v.findViewById(R.id.hide2);
String s="http://166.62.17.208//images_large/caeser-salad.jpg";
ImageView picture=(ImageView)v.findViewById(R.id.imageView1);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO)
.enableLogging()
.build();
ImageLoader.getInstance().init(config);
DisplayImageOptions options = new …Run Code Online (Sandbox Code Playgroud) android nullpointerexception simpleadapter universal-image-loader