本文整理匯總了Java中android.support.wearable.view.WearableListView類的典型用法代碼示例。如果您正苦於以下問題:Java WearableListView類的具體用法?Java WearableListView怎麽用?Java WearableListView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WearableListView類屬於android.support.wearable.view包,在下文中一共展示了WearableListView類的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: onCreate
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_with_header);
// Get the list component from the layout of the activity
final WearableListView listView = (WearableListView) findViewById(R.id.devices_list);
listView.setAdapter(mDeviceAdapter = new DevicesAdapter(listView));
listView.setClickListener(mOnRowClickListener);
listView.addOnScrollListener(mOnScrollListener);
// The header will be moved as the list is scrolled
mHeader = findViewById(R.id.header);
// Register a broadcast receiver that will listen for events from the service.
LocalBroadcastManager.getInstance(this).registerReceiver(mServiceBroadcastReceiver, BleProfileService.makeIntentFilter());
}
示例3: 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();
}
}
示例4: 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);
}
示例5: onCreate
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
elements = getElements();
setContentView(R.layout.actions_list_activity);
// Get the list component from the layout of the activity
WearableListView listView =
(WearableListView) findViewById(R.id.wearable_list);
// Assign an adapter to the list
listView.setAdapter(new Adapter(this, elements));
// Set a click listener
listView.setClickListener(this);
}
示例6: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder viewHolder, int position ) {
BackgroundItemViewHolder holder = (BackgroundItemViewHolder) viewHolder;
String backgroundName = mBackgrounds[ position ];
holder.mBackgroundItem.setBackground( backgroundName, position );
RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT );
int backgroundPickerItemMargin = (int) getResources().getDimension( R.dimen.background_picker_item_margin );
if( position == 0 ) {
layoutParams.setMargins( 0, backgroundPickerItemMargin, 0, 0 );
} else if( position == mBackgrounds.length - 1 ) {
layoutParams.setMargins( 0, 0, 0, backgroundPickerItemMargin );
} else {
layoutParams.setMargins( 0, 0, 0, 0 );
}
holder.itemView.setLayoutParams( layoutParams );
}
示例7: onCreate
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wear_list_view);
appPrefs = new AppPreferences(getApplicationContext());
followRadiusAdapter = new FollowMeRadiusAdapter(UnitManager.getUnitSystem(appPrefs.getUnitSystemType())
.getLengthUnitProvider());
radiusSelectorView = (WearableListView) findViewById(R.id.wear_list);
radiusSelectorView.setAdapter(followRadiusAdapter);
radiusSelectorView.setClickListener(this);
handleIntent(getIntent());
}
示例8: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
final SoundProfile profile = SoundProfile.values()[position];
final ProfileViewHolder profileViewHolder = (ProfileViewHolder) holder;
switch (profile) {
case SOUND_ON:
profileViewHolder.tvProfileName.setText(context.getString(R.string.sound_profile_on));
profileViewHolder.ivProfileImage.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_volume_up_black_48dp));
break;
case SOUND_OFF:
profileViewHolder.tvProfileName.setText(context.getString(R.string.sound_profile_off));
profileViewHolder.ivProfileImage.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_volume_off_black_48dp));
break;
case VIBRATE:
profileViewHolder.tvProfileName.setText(context.getString(R.string.sound_profile_vibrate));
profileViewHolder.ivProfileImage.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_vibrate));
break;
default:
profileViewHolder.tvProfileName.setText("unknown");
break;
}
}
示例9: 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);
colorItemViewHolder.mColorItem.setBitmapResource(previewResource);
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);
}
開發者ID:marcouberti,項目名稱:american_sunsets_watch_face,代碼行數:23,代碼來源:SunsetsGeneralWearableConfigActivity.java
示例10: onCreate
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_watch_face_config);
val = new Values(getApplicationContext());
// Get the list component from the layout of the activity
WearableListView listView =
(WearableListView) findViewById(R.id.wearable_list);
// Assign an adapter to the list
listView.setAdapter(new ListAdapter(this, elements));
// Set a click listener
listView.setClickListener(this);
}
示例11: onCreate
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_config_wear_default);
final Configuration parent = (Configuration) getIntent().getSerializableExtra(EXTRA_PARENT);
final int selectedIndex = getIntent().getIntExtra(EXTRA_SELECTED_INDEX, 0);
final WearableListView listView = (WearableListView) findViewById(R.id.list_config);
listView.setAdapter(new SelectionAdapter(getItems(parent)));
listView.scrollToPosition(selectedIndex);
listView.setClickListener(new WearableListView.ClickListener() {
@Override
public void onClick(final WearableListView.ViewHolder viewHolder) {
final Serializable selection = (Serializable) viewHolder.itemView.getTag();
final Intent data = new Intent();
data.putExtra(EXTRA_PARENT, parent);
data.putExtra(EXTRA_RESULT, selection);
setResult(RESULT_OK, data);
finish();
}
@Override
public void onTopEmptyRegionClick() { }
});
}
示例12: onCreate
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_config_wear_default);
apiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wearable.API)
.build();
onBeforeListViewSetup(apiClient);
final WearableListView listView = (WearableListView) findViewById(R.id.list_config);
listView.setAdapter(getListAdapter());
listView.setClickListener(getListClickListener());
}
示例13: onBindViewHolder
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
@Override
public void onBindViewHolder(WearableListView.ViewHolder viewHolder, int i)
{
String currentValue = this.elements.get(i);
ItemListView itemView = (ItemListView) viewHolder.itemView;
TextView txtView = (TextView) itemView.findViewById(R.id.text);
txtView.setText(this.elements.get(i));
CircledImageView imgView = (CircledImageView) itemView.findViewById(R.id.image);
if(this.selectedElements == null) {
imgView.setImageResource(android.R.color.transparent);
return;
}
for(String activ : selectedElements) { // mark activity and subactivity if subactivity is activ
if(activ.equals(currentValue) || activ.startsWith(currentValue + Settings.ACTIVITY_DELIMITER) || (this.parent != null && activ.equals(this.parent + Settings.ACTIVITY_DELIMITER + currentValue))) {
imgView.setImageResource(R.drawable.yes);
return;
}
}
imgView.setImageResource(android.R.color.transparent);
}
示例14: handleIntent
import android.support.wearable.view.WearableListView; //導入依賴的package包/類
private void handleIntent(Intent intent) {
VehicleMode flightMode = intent.getParcelableExtra(WearReceiverService.EXTRA_EVENT_DATA);
if(flightMode == null)
flightMode = VehicleMode.UNKNOWN;
List<VehicleMode> vehicleModes = VehicleMode.getVehicleModePerDroneType(flightMode.getDroneType());
WearableListView listView = (WearableListView) findViewById(R.id.wear_list);
listView.setAdapter(new VehicleModeAdapter(vehicleModes));
listView.setClickListener(this);
RecyclerView.LayoutManager layoutMgr = listView.getLayoutManager();
if (layoutMgr != null) {
int currentPos = vehicleModes.indexOf(flightMode);
if (currentPos != -1)
layoutMgr.scrollToPosition(currentPos);
}
}
示例15: 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);
}
}