本文整理匯總了Java中android.support.wearable.view.WearableListView.ViewHolder方法的典型用法代碼示例。如果您正苦於以下問題:Java WearableListView.ViewHolder方法的具體用法?Java WearableListView.ViewHolder怎麽用?Java WearableListView.ViewHolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.wearable.view.WearableListView
的用法示例。
在下文中一共展示了WearableListView.ViewHolder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(final WearableListView.ViewHolder holder, final int position) {
final ItemViewHolder viewHolder = (ItemViewHolder) holder;
if (position < mDevices.size()) {
final BluetoothDevice device = mDevices.get(position);
viewHolder.mDevice = device;
viewHolder.mName.setText(TextUtils.isEmpty(device.getName()) ? mNotAvailable : device.getName());
viewHolder.mAddress.setText(getState(device, position));
viewHolder.mIcon.showIndeterminateProgress(position == mConnectingPosition);
} else {
viewHolder.mDevice = null;
viewHolder.mName.setText(mScanning ? R.string.devices_list_scanning : R.string.devices_list_start_scan);
viewHolder.mAddress.setText(null);
viewHolder.mIcon.showIndeterminateProgress(mScanning);
}
}
示例2: onClick
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onClick(final WearableListView.ViewHolder holder) {
final DevicesAdapter.ItemViewHolder viewHolder = (DevicesAdapter.ItemViewHolder) holder;
final BluetoothDevice device = viewHolder.getDevice();
if (device != null) {
mDeviceAdapter.stopLeScan();
mDeviceAdapter.setConnectingPosition(holder.getAdapterPosition());
// Start the service that will connect to selected device
final Intent service = new Intent(ScannerActivity.this, BleProfileService.class);
service.putExtra(BleProfileService.EXTRA_DEVICE_ADDRESS, device.getAddress());
startService(service);
} else {
mDeviceAdapter.startLeScan();
}
}
示例3: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
ColorItemViewHolder colorItemViewHolder = (ColorItemViewHolder) holder;
String colorName = mColors[position];
colorItemViewHolder.mColorItem.setColor(colorName);
RecyclerView.LayoutParams layoutParams =
new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
int colorPickerItemMargin = (int) getResources()
.getDimension(R.dimen.digital_config_color_picker_item_margin);
// Add margins to first and last item to make it possible for user to tap on them.
if (position == 0) {
layoutParams.setMargins(0, colorPickerItemMargin, 0, 0);
} else if (position == mColors.length - 1) {
layoutParams.setMargins(0, 0, 0, colorPickerItemMargin);
} else {
layoutParams.setMargins(0, 0, 0, 0);
}
colorItemViewHolder.itemView.setLayoutParams(layoutParams);
}
示例4: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder,
int position) {
// retrieve the text view
ItemViewHolder itemHolder = (ItemViewHolder) holder;
ImageView ivAppIcon = itemHolder.ivAppIcon;
TextView tvAppName = itemHolder.tvAppName;
TextView tvPkgSize = itemHolder.tvPkgSize;
// replace text contents
ApplicationInfo entry = (ApplicationInfo) mListAppInfo.get(position);
ivAppIcon.setImageDrawable(entry.loadIcon(mPm));
tvAppName.setText(entry.loadLabel(mPm));
tvPkgSize.setText("");
// replace list item's metadata
holder.itemView.setTag(position);
}
示例5: onClick
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onClick(WearableListView.ViewHolder viewHolder)
{
// parse data
String position = Chooser.this.adapterPosition.get(viewHolder.getPosition());
// update mobile device
BroadcastService.getInstance().sendMessage("/position/update", position);
// update local device
MainActivity mc = (MainActivity) ActivityController.getInstance().get("MainActivity");
mc.updatePositionView(position);
// finish
Chooser.this.finish();
Chooser.this.overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
}
示例6: onClick
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onClick(WearableListView.ViewHolder v) {
Integer tag = (Integer) v.itemView.getTag();
if (elements[tag].equals("EnableTicks")) {
val.setBoolean("EnableTicks", !val.getBoolean("EnableTicks"));
finish();
} else if (elements[tag].equals("EnableShadows")) {
val.setBoolean("EnableShadows", !val.getBoolean("EnableShadows"));
finish();
} else if (elements[tag].equals("ResetSettings")) {
val.resetValues();
finish();
} else {
Intent intent = new ColorPickActivity.IntentBuilder().oldColor(val.getColor(elements[tag])).build(this);
startActivityForResult(intent, tag);
}
}
示例7: onClick
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onClick(final WearableListView.ViewHolder viewHolder) {
if (viewHolder instanceof UARTConfigurationsAdapter.ConfigurationViewHolder) {
final UARTConfigurationsAdapter.ConfigurationViewHolder holder = (UARTConfigurationsAdapter.ConfigurationViewHolder) viewHolder;
final UartConfiguration configuration = holder.getConfiguration();
final Intent intent = new Intent(this, UARTCommandsActivity.class);
intent.putExtra(UARTCommandsActivity.CONFIGURATION, configuration);
startActivity(intent);
}
}
示例8: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder,
int position) {
// retrieve the text view
ItemViewHolder itemHolder = (ItemViewHolder) holder;
TextView view = itemHolder.descriptionText;
// replace text contents
view.setText(mDataset.get(position).getString("description"));
// replace list item's metadata
holder.itemView.setTag(position);
ImageView mCircle = itemHolder.priorityCircleImage;
int result;
int prior = Integer.valueOf(mDataset.get(position).getString("priority"));
switch (prior) {
case Constants.STATE_NOT_CLASSIFIED:
result = R.color.not_classified_color;
break;
case Constants.STATE_INFORMATION:
result = R.color.information_color;
break;
case Constants.STATE_WARNING:
result = R.color.warning_color;
break;
case Constants.STATE_AVERAGE:
result = R.color.average_color;
break;
case Constants.STATE_HIGH:
result = R.color.high_color;
break;
case Constants.STATE_DISASTER:
result = R.color.disaster_color;
break;
default:
result = R.color.not_classified_color;
break;
}
((GradientDrawable) mCircle.getDrawable()).setColor(mContext.getResources().getColor(result));
}
示例9: onClick
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onClick(WearableListView.ViewHolder viewHolder) {
int pos = viewHolder.getAdapterPosition();
getSharedPreferences("config", 0).edit()
.putInt(mComplicationId + "_selected_position", pos)
.putString(mComplicationId + "_selected_currency_name", mElements[pos])
.putString(mComplicationId + "_selected_currency_symbol", mSymbols[pos])
.putString(mComplicationId + "_selected_currency_ticker", mTickers[pos])
.putInt(mComplicationId + "_selected_currency_invert", mInvert[pos])
.apply();
setResult(RESULT_OK);
ComplicationService.requestUpdateComplication(this, mComplicationId);
finish();
}
示例10: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder,
int position) {
// retrieve the text view
ItemViewHolder itemHolder = (ItemViewHolder) holder;
TextView view = itemHolder.textView;
// replace text contents
view.setText(mDataset[position]);
// replace list item's metadata
holder.itemView.setTag(mDataset[position]);
}
示例11: onClick
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onClick(WearableListView.ViewHolder viewHolder) {
int clickedMenu = viewHolder.getLayoutPosition();
switch (clickedMenu) {
case WearableAdapter.ITEM_LOCALIZATION:
startActivity(new Intent(MainWatchActivity.this, WatchLocalizationActivity.class));
break;
case PositionsHelper.ITEM_SCAN11:
case PositionsHelper.ITEM_SCAN12:
case PositionsHelper.ITEM_SCAN21:
case PositionsHelper.ITEM_SCAN22:
case PositionsHelper.ITEM_SCAN31:
case PositionsHelper.ITEM_SCAN32:
case PositionsHelper.ITEM_SCAN41:
case PositionsHelper.ITEM_SCAN42:
Intent intent = new Intent(MainWatchActivity.this, ProcessingActivity.class);
intent.putExtra("mode", "measure");
intent.putExtra("placeId", PositionsHelper.getMenuLabelForPosition(clickedMenu));
startActivity(intent);
break;
case WearableAdapter.ITEM_CALCULATE:
intent = new Intent(MainWatchActivity.this, ProcessingActivity.class);
intent.putExtra("mode", "average");
startActivity(intent);
break;
case WearableAdapter.ITEM_DELETE:
mMeasureClass.deleteAllMeasurements();
break;
default:
Toast.makeText(MainWatchActivity.this,
String.format("You selected item #%s",
viewHolder.getLayoutPosition() + 1),
Toast.LENGTH_SHORT).show();
break;
}
}
示例12: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder viewHolder,
int position) {
ItemViewHolder itemViewHolder = (ItemViewHolder) viewHolder;
CircledImageView circledView = itemViewHolder.mCircledImageView;
circledView.setImageResource(mItems.get(position));
TextView textView = itemViewHolder.mItemTextView;
switch (position) {
case ITEM_LOCALIZATION:
textView.setText(R.string.menu_start_localization);
break;
case PositionsHelper.ITEM_SCAN11:
case PositionsHelper.ITEM_SCAN12:
case PositionsHelper.ITEM_SCAN21:
case PositionsHelper.ITEM_SCAN22:
case PositionsHelper.ITEM_SCAN31:
case PositionsHelper.ITEM_SCAN32:
case PositionsHelper.ITEM_SCAN41:
case PositionsHelper.ITEM_SCAN42:
String menuText = String.format(Locale.getDefault(), mRes.getString(R.string.menu_measure_place), PositionsHelper.getMenuLabelForPosition(position));
textView.setText(menuText);
break;
case ITEM_CALCULATE:
textView.setText(R.string.menu_calculate_average);
break;
case ITEM_DELETE:
textView.setText(R.string.menu_delete_all_measurements);
break;
}
}
示例13: onClick
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public void onClick(WearableListView.ViewHolder v) {
String tag = (String) v.itemView.getTag();
doAction(tag);
//ActionsDefinitions.doAction(v.getAdapterPosition(), this);
finish();
}
示例14: onCreateViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
/**
* Create a ViewHolder that will hold a reference to the views that
* we will need to update for each new item in the list.
*/
@SuppressLint("InflateParams")
@Override
public WearableListView.ViewHolder onCreateViewHolder(
ViewGroup viewGroup, int i) {
// Return a new ViewHolder (see below for class ViewHolder).
// Each view in our list will use the item_task.xml layout.
return new ViewHolder(
inflater.inflate(R.layout.item_task, null));
}
示例15: onCreateViewHolder
import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
WearMenuListItemLayout layout = (WearMenuListItemLayout) mInflater.inflate(R.layout.wearmenu_list_element, null);
layout.setListSelectedColor(mListSelectedColor);
layout.setListTextColor(mListTextColor);
return new WearMenuListViewAdapterViewHolder(layout);
}