本文整理匯總了Java中android.widget.SimpleAdapter.notifyDataSetChanged方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleAdapter.notifyDataSetChanged方法的具體用法?Java SimpleAdapter.notifyDataSetChanged怎麽用?Java SimpleAdapter.notifyDataSetChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.SimpleAdapter
的用法示例。
在下文中一共展示了SimpleAdapter.notifyDataSetChanged方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onGetInputtips
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
@Override
public void onGetInputtips(List<Tip> tipList, int rCode) {
if (rCode == AMapException.CODE_AMAP_SUCCESS) {
List<HashMap<String, String>> listString = new ArrayList<>();
for (int i = 0; i < tipList.size(); i++) {
HashMap<String, String> map = new HashMap<>();
map.put("name", tipList.get(i).getName());
map.put("address", tipList.get(i).getDistrict());
listString.add(map);
}
SimpleAdapter aAdapter = new SimpleAdapter(this, listString, R.layout.item_find_city_search,
new String[]{"name", "address"}, new int[]{R.id.poi_name, R.id.poi_address});
mSearchText.setAdapter(aAdapter);
aAdapter.notifyDataSetChanged();
mSearchText.setOnItemClickListener((adapterView, view, position, id) -> {
mSearchText.setText(listString.get(position).get("name"));
Intent intent = new Intent();
intent.putExtra(Constants.ARG_POIITEM, listString.get(position).get("name"));
setResult(RESULTCODE, intent);
// finish();
showToast(listString.get(position).get("name"));
});
} else {
ToastUtils.showToast(this.getApplicationContext(), String.valueOf(rCode));
}
}
示例2: onSuccess
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
public void onSuccess(API api, int action, Map<String, Object> result) {
ArrayList<Map<String, Object>> res = forceCast(result.get("result"));
SimpleAdapter adapter = new SimpleAdapter(this, res, R.layout.view_exchange_currency_item,
new String[]{"code", "name"}, new int[]{R.id.tvCurrencyCode, R.id.tvCurrencyName});
lvResult.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
示例3: onActivityResult
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
protected void onActivityResult (int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
ContentResolver reContentResolverol = getContentResolver();
Uri contactData = data.getData();
@SuppressWarnings("deprecation")
Cursor cursor = managedQuery(contactData, null, null, null, null);
cursor.moveToFirst();
name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
Cursor phone = reContentResolverol.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId,
null,
null);
while (phone.moveToNext()) {
number = phone.getString(phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
isfrist=false;
//add a contact
db.open();
long id = db.insertContact(name, number);
if(isfrist !=true)
{
//get a contact
db.open();
Cursor a = db.getContact(id);
if (a.moveToLast()){
Map<String, Object> map = new HashMap<String, Object>();
map.put("contacts_name", name);
map.put("contacts_num", number);
dataList.add(map);
simpleadapter = new SimpleAdapter(this, dataList, R.layout.contact_text, new String[]{"contacts_name","contacts_num"},
new int[]{R.id.contacts_name,R.id.contacts_num});
listView.setAdapter(simpleadapter);
simpleadapter.notifyDataSetChanged();
// DisplayContact(a);
}
else
Toast.makeText(this, "No contact found!", Toast.LENGTH_SHORT).show();
}
db.close();
}
}
示例4: onCreateView
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fr_json_request, container,false);
carDataList = new ArrayList<Map<String, String>>();
lvCar = (ListView) view.findViewById(R.id.lv_car);
adapter = new SimpleAdapter(getActivity(), carDataList, R.layout.fr_json_request_list_item, keys, ids);
lvCar.setAdapter(adapter);
// 發起請求
JsonObjectRequest request = new JsonObjectRequest(StringUtil.preUrl(Constants.DEFAULT_JSON_REQUEST_URL), null,
new Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
if (!response.has("result")) {
return;
}
JSONObject result = response.getJSONObject("result");
if (!result.has("fctlist")) {
return;
}
JSONArray factoryArray = result.getJSONArray("fctlist");
if (factoryArray.length() == 0) {
return;
}
JSONObject factory = factoryArray.getJSONObject(0);
if (!factory.has("serieslist")) {
return;
}
JSONArray seriesArray = factory.getJSONArray("serieslist");
carDataList.clear();
for (int i = 0; i < seriesArray.length(); i++) {
JSONObject series = seriesArray.getJSONObject(i);
Map<String, String> seriesMap = new HashMap<String, String>();
seriesMap.put("name", series.getString("name"));
seriesMap.put("level", "級別:"+series.getString("levelname"));
seriesMap.put("price", "價格:"+series.getString("price"));
carDataList.add(seriesMap);
}
adapter.notifyDataSetChanged();
} catch (Exception e) {
ToastUtil.showToast(getActivity(), getResources().getString(R.string.request_fail_text));
}
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError arg0) {
ToastUtil.showToast(getActivity(), getResources().getString(R.string.request_fail_text));
}
});
// 請求加上Tag,用於取消請求
request.setTag(this);
VolleyUtil.getQueue(getActivity()).add(request);
return view;
}
示例5: onCreate
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);// ȡ��������
setContentView(R.layout.cjlistinfo);
// ���汾����4.4����Ϊ����ʽ״̬��
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
SystemBartint.setTranslucentStatus(true, ListInfo.this);
}
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintColor(Color.parseColor("#2B78E4"));
// ��ȡ���
listview = (ListView) findViewById(R.id.listView1);
listview.setVerticalScrollBarEnabled(false);// ���ع�����
String inforesult = showinfo(url);
if (!inforesult.equals("erro")) {
char result[] = new char[inforesult.length() - 1];
for (int i = 0; i < result.length; i++) {
if (inforesult.charAt(i) == '*') {
result[i] = '\n';
}
else {
result[i] = inforesult.charAt(i);
}
}
inforesult = new String(result);// char������Ϊ���캯��������ֵ
String data[] = inforesult.split("\n");
ArrayList<HashMap<String, Object>> listinfo = new ArrayList<HashMap<String, Object>>();
for (int i = 0; i < data.length; i++) {
HashMap<String, Object> map = new HashMap<String, Object>();
String data2[] = data[i].trim().split(" ");
map.put("kc_name", data2[0]);
map.put("kc_teacher", data2[1]);
map.put("kc_cj", data2[2]);
listinfo.add(map);
}
SimpleAdapter adapter = new SimpleAdapter(this, listinfo,
R.layout.cj, new String[] { "kc_name", "kc_teacher",
"kc_cj" }, new int[] { R.id.kc_name,
R.id.kc_teacher, R.id.kc_cj });
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
} else {
Intent intent = new Intent(ListInfo.this, ListInfo_Null.class);
startActivity(intent);
}
}