本文整理匯總了Java中android.widget.SimpleAdapter.setViewBinder方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleAdapter.setViewBinder方法的具體用法?Java SimpleAdapter.setViewBinder怎麽用?Java SimpleAdapter.setViewBinder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.SimpleAdapter
的用法示例。
在下文中一共展示了SimpleAdapter.setViewBinder方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: FillLists
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
void FillLists() {
// We use a - sign to tell that this text should be stiked through
SimpleAdapter.ViewBinder vb = new SimpleAdapter.ViewBinder() {
public boolean setViewValue(View view, Object data, String textRepresentation) {
TextView tv = (TextView) view;
tv.setText(textRepresentation.substring(1));
if(textRepresentation.substring(0, 1).equals("-")) {
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
return true;
}
};
ArrayList<HashMap<String, String>> feedList;
feedList = createAlertsMap(false);
SimpleAdapter simpleAdapterLow = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
simpleAdapterLow.setViewBinder(vb);
listViewLow.setAdapter(simpleAdapterLow);
feedList = createAlertsMap(true);
SimpleAdapter simpleAdapterHigh = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
simpleAdapterHigh.setViewBinder(vb);
listViewHigh.setAdapter(simpleAdapterHigh);
}
示例2: FillLists
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
void FillLists() {
// We use a - sign to tell that this text should be stiked through
SimpleAdapter.ViewBinder vb = new SimpleAdapter.ViewBinder() {
public boolean setViewValue(View view, Object data, String textRepresentation) {
TextView tv = (TextView) view;
tv.setText(textRepresentation.substring(1));
if (textRepresentation.substring(0, 1).equals("-")) {
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
return true;
}
};
ArrayList<HashMap<String, String>> feedList;
feedList = createAlertsMap(false);
SimpleAdapter simpleAdapterLow = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
simpleAdapterLow.setViewBinder(vb);
listViewLow.setAdapter(simpleAdapterLow);
feedList = createAlertsMap(true);
SimpleAdapter simpleAdapterHigh = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
simpleAdapterHigh.setViewBinder(vb);
listViewHigh.setAdapter(simpleAdapterHigh);
}
示例3: displayGrid
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
void displayGrid() {
SimpleAdapter adapter = new SimpleAdapter(this, imageDirectoryMaps,
R.layout.imagegrid_cell,
new String[] {"thumbnailURI"},
new int[] {R.id.grid_image});
adapter.setViewBinder(new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object data, String textRepresentation) {
Uri imageUri = (Uri)data;
imageLoader.loadImageIntoViewAsync(bitmapCache, imageUri, (ImageView)view, CELL_WIDTH, CELL_HEIGHT, getResources());
return true;
}
});
gridView.setAdapter(adapter);
// show text message if no images available
View noImagesView = findViewById(R.id.noImagesTextView);
noImagesView.setVisibility(imageDirectoryMaps.size()>0 ? View.GONE : View.VISIBLE);
System.gc(); // seems to avoid OutOfMemoryErrors when selecting image after deleting earlier image
}
示例4: createOfferListAdapter
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
/**
* Creates ListAdapter populated with offer information.
* @param offers the list of offers used to populate the adapter.
* @return an adapter populated with offer information.
*/
private ListAdapter createOfferListAdapter(final List<Offer> offers) {
List<Map<String, Object>> data = new ArrayList<>();
for (Offer offer : offers) {
Map<String, Object> map = new HashMap<>();
map.put("offerIcon", offer.getImageUrl());
map.put("offerTitle", offer.getTitle());
map.put("offerDetails", offer.getDescription());
data.add(map);
}
SimpleAdapter adapter = new SimpleAdapter(PlaceDetailsActivity.this,
data,
R.layout.offer_item,
new String[]{"offerIcon", "offerTitle", "offerDetails"},
new int[]{R.id.offer_Image, R.id.offer_name,
R.id.offer_description});
adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
return adapter;
}
示例5: createRecommendationsListAdapter
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
/**
* Creates ListAdapter populated with recommendation information.
* @param recommendations the list of recommendations used to populate
* the adapter.
* @return an adapter populated with recommendation information.
*/
private ListAdapter createRecommendationsListAdapter(
final List<Recommendation> recommendations) {
List<Map<String, Object>> data = new ArrayList<>();
for (Recommendation recommendation : recommendations) {
Map<String, Object> map = new HashMap<>();
map.put("productImage", recommendation.getImageUrl());
map.put("recommendationTitle", recommendation.getTitle());
map.put("recommendationDetails",
recommendation.getDescription());
data.add(map);
}
SimpleAdapter adapter = new SimpleAdapter(PlaceDetailsActivity.this,
data,
R.layout.offer_item,
new String[]{"productImage", "recommendationTitle",
"recommendationDetails"},
new int[]{R.id.offer_Image, R.id.offer_name,
R.id.offer_description});
adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
return adapter;
}
示例6: onPostExecute
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
protected void onPostExecute(ArrayList<HashMap<String, Object>> result) {
if (result.isEmpty()) {
String err = getResources().getString(R.string.noApp);
Toast.makeText(AppSearchActivity.this, err, Toast.LENGTH_SHORT).show();
}
SimpleAdapter simpleAdapter = new SimpleAdapter(AppSearchActivity.this, result,
R.layout.item, new String[]{"appName", "packageId", "appIcon"},
new int[]{R.id.app_name, R.id.package_id, R.id.icon}
);
mAppLv.setAdapter(simpleAdapter);
simpleAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
public boolean setViewValue(View view, Object data, String textRepresentation) {
if (view instanceof ImageView && data instanceof Drawable) {
ImageView iv = (ImageView) view;
iv.setImageDrawable((Drawable) data);
return true;
} else {
return false;
}
}
});
}
示例7: initAdapter
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
public void initAdapter()
{
items = new ArrayList<Map<String,Object>>();
//實例化一個適配器
adapter = new SimpleAdapter(HCActivity.this, items,
R.layout.hc_list_item,
new String[]{"imageItem", "fileName","delay","filePath"},
new int[]{R.id.image_item, R.id.hc_tv_filename,R.id.tv_delay}
);
list.setAdapter(adapter);
adapter.setViewBinder(new ViewBinder(){
@Override
public boolean setViewValue(View p1, Object p2, String p3)
{
if (p1 instanceof ImageView && p2 instanceof Bitmap)
{
ImageView iv = (ImageView) p1;
iv.setImageBitmap((Bitmap) p2);
return true;
}
else
return false;
}
});
}
示例8: onAttach
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
ArrayList<Map<String, ExoAccount>> data = new ArrayList<Map<String, ExoAccount>>(accounts.size());
for (ExoAccount account : accounts) {
Map<String, ExoAccount> map = new HashMap<String, ExoAccount>();
map.put("ACCOUNT_DATA", account);
data.add(map);
}
String[] from = { "ACCOUNT_DATA" };
int[] to = new int[] { R.id.share_account_item_layout };
SimpleAdapter adapter = new SimpleAdapter(activity, data, R.layout.share_extension_account_item, from, to);
adapter.setViewBinder(this);
setListAdapter(adapter);
}
示例9: onActivityCreated
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
prefsWrapper = new PreferencesWrapper(getActivity());
useCodecsPerSpeed = SipConfigManager.getPreferenceBooleanValue(getActivity(), SipConfigManager.CODECS_PER_BANDWIDTH);
initDatas();
setHasOptionsMenu(true);
// Adapter
mAdapter = new SimpleAdapter(getActivity(), codecsList, R.layout.codecs_list_item, new String[] {
CODEC_NAME,
CODEC_NAME,
CODEC_PRIORITY
}, new int[] {
R.id.line1,
R.id.AccCheckBoxActive,
R.id.entiere_line
});
mAdapter.setViewBinder(new ViewBinder() {
@Override
public boolean setViewValue(View view, Object data, String textRepresentation) {
if (view.getId() == R.id.entiere_line) {
Log.d(THIS_FILE, "Entiere line is binded ");
TextView tv = (TextView) view.findViewById(R.id.line1);
ImageView grabber = (ImageView) view.findViewById(R.id.icon);
CompoundButton checker = (CompoundButton) view.findViewById(R.id.AccCheckBoxActive);
checker.setOnCheckedChangeListener(CodecsFragment.this);
if ((Short) data == 0) {
tv.setTextColor(Color.GRAY);
grabber.setVisibility(View.GONE);
checker.setChecked(false);
} else {
tv.setTextColor(Color.WHITE);
grabber.setVisibility(View.VISIBLE);
checker.setChecked(true);
}
return true;
}else if(view.getId() == R.id.AccCheckBoxActive) {
view.setTag(data);
return true;
}
return false;
}
});
setListAdapter(mAdapter);
registerForContextMenu(getListView());
}
示例10: refreshAppListView
import android.widget.SimpleAdapter; //導入方法依賴的package包/類
private boolean refreshAppListView() {
// Get installed packages
ArrayList<HashMap<String, Object>> appList = new ArrayList<HashMap<String, Object>>();
if (sPkgInfoList == null) {
sPkgInfoList = mPkgMgr.getInstalledPackages(0);
}
for (PackageInfo pkg : sPkgInfoList) {
// Skip Ourself
if (pkg.packageName.equalsIgnoreCase(getPackageName()))
continue;
// Skip Android packages
if (mCheckBoxHideAndroid.isChecked()) {
if (pkg.packageName.contains(PKG_PREFIX_ANDROID))
continue;
}
// Skip Google packages
if (mCheckBoxHideGoogle.isChecked()) {
if (pkg.packageName.contains(PKG_PREFIX_GOOGLE))
continue;
}
HashMap<String, Object> mapApp = new HashMap<String, Object>();
mapApp.put(APP_PKG, pkg.packageName);
mapApp.put(APP_NAME, pkg.applicationInfo.loadLabel(mPkgMgr));
mapApp.put(APP_ICON, pkg.applicationInfo.loadIcon(mPkgMgr));
appList.add(mapApp);
}
// Bind ListView with content adapter
SimpleAdapter appAdapter = new SimpleAdapter(this, appList, R.layout.app_list_item,
new String[] {
APP_NAME, APP_PKG, APP_ICON
},
new int[] {
R.id.appName, R.id.appPackage, R.id.appIcon
});
appAdapter.setViewBinder(new ViewBinder() {
public boolean setViewValue(View view, Object data, String textRepresentation) {
if (view instanceof ImageView && data instanceof Drawable) {
ImageView iv = (ImageView) view;
iv.setImageDrawable((Drawable) data);
return true;
}
else
return false;
}
});
mListView.setAdapter(appAdapter);
return true;
}