本文整理汇总了Java中android.widget.SpinnerAdapter类的典型用法代码示例。如果您正苦于以下问题:Java SpinnerAdapter类的具体用法?Java SpinnerAdapter怎么用?Java SpinnerAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpinnerAdapter类属于android.widget包,在下文中一共展示了SpinnerAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAdapter
import android.widget.SpinnerAdapter; //导入依赖的package包/类
/**
* Set an adapter for this Spinner.
* @param adapter
*/
public void setAdapter(SpinnerAdapter adapter) {
if(mAdapter != null)
mAdapter.unregisterDataSetObserver(mDataSetObserver);
mRecycler.clear();
mAdapter = adapter;
mAdapter.registerDataSetObserver(mDataSetObserver);
onDataChanged();
if (mPopup != null)
mPopup.setAdapter(new DropDownAdapter(adapter));
else
mTempAdapter = new DropDownAdapter(adapter);
}
示例2: getDropDownView
import android.widget.SpinnerAdapter; //导入依赖的package包/类
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
for (ListAdapter piece : getPieces()) {
int size = piece.getCount();
if (position < size) {
return (((SpinnerAdapter) piece).getDropDownView(position,
convertView,
parent));
}
position -= size;
}
return (null);
}
示例3: onMeasure
import android.widget.SpinnerAdapter; //导入依赖的package包/类
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
SpinnerAdapter adapter = getAdapter();
if (adapter != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) {
View view = adapter.getView(getSelectedItemPosition(), null, this);
if (view.getLayoutParams() == null)
view.setLayoutParams(mDefaultLayoutParams);
view.measure(widthMeasureSpec, heightMeasureSpec);
int width = view.getMeasuredWidth();
if (getBackground() != null) {
getBackground().getPadding(mTempRect);
width += mTempRect.left + mTempRect.right;
}
this.setMeasuredDimension(Math.min(width, MeasureSpec.getSize(widthMeasureSpec)), this.getMeasuredHeight());
}
}
示例4: DropDownAdapter
import android.widget.SpinnerAdapter; //导入依赖的package包/类
public DropDownAdapter(@Nullable SpinnerAdapter adapter, @Nullable Theme dropDownTheme) {
this.mAdapter = adapter;
if (adapter instanceof ListAdapter) {
this.mListAdapter = (ListAdapter) adapter;
}
if (dropDownTheme == null) {
return;
}
if (AppCompatSpinner.IS_AT_LEAST_M && (adapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedAdapter = (ThemedSpinnerAdapter) adapter;
if (themedAdapter.getDropDownViewTheme() != dropDownTheme) {
themedAdapter.setDropDownViewTheme(dropDownTheme);
}
} else if (adapter instanceof ThemedSpinnerAdapter) {
ThemedSpinnerAdapter themedAdapter2 = (ThemedSpinnerAdapter) adapter;
if (themedAdapter2.getDropDownViewTheme() == null) {
themedAdapter2.setDropDownViewTheme(dropDownTheme);
}
}
}
示例5: setAdapter
import android.widget.SpinnerAdapter; //导入依赖的package包/类
@Override
public void setAdapter(SpinnerAdapter adapter) {
if (!_isFromInit) {
_arrayAdapter = (ArrayAdapter) adapter;
if (!TextUtils.isEmpty(_strHintText) && !_isDirty) {
ArrayAdapter arrayAdapter = new ArrayAdapter(_context, android.R.layout
.simple_list_item_1, new String[]{_strHintText});
super.setAdapter(arrayAdapter);
} else {
super.setAdapter(adapter);
}
} else {
_isFromInit = false;
super.setAdapter(adapter);
}
}
示例6: setAdapter
import android.widget.SpinnerAdapter; //导入依赖的package包/类
/**
* Set an adapter for this Spinner.
* @param adapter
*/
public void setAdapter(SpinnerAdapter adapter) {
if(mAdapter != null)
mAdapter.unregisterDataSetObserver(mDataSetObserver);
mRecycler.clear();
mAdapter = adapter;
mAdapter.registerDataSetObserver(mDataSetObserver);
onDataChanged();
if (mPopup != null)
mPopup.setAdapter(new DropDownAdapter(adapter));
else
mTempAdapter = new DropDownAdapter(adapter);
}
示例7: bi
import android.widget.SpinnerAdapter; //导入依赖的package包/类
public bi(SpinnerAdapter spinnerAdapter, Theme theme) {
this.f1367a = spinnerAdapter;
if (spinnerAdapter instanceof ListAdapter) {
this.f1368b = (ListAdapter) spinnerAdapter;
}
if (theme == null) {
return;
}
if (bg.f1353a && (spinnerAdapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) spinnerAdapter;
if (themedSpinnerAdapter.getDropDownViewTheme() != theme) {
themedSpinnerAdapter.setDropDownViewTheme(theme);
}
} else if (spinnerAdapter instanceof dd) {
dd ddVar = (dd) spinnerAdapter;
if (ddVar.m2705a() == null) {
ddVar.m2706a(theme);
}
}
}
示例8: setAdapter
import android.widget.SpinnerAdapter; //导入依赖的package包/类
@Override
public void setAdapter(SpinnerAdapter adapter) {
// The super constructor may call setAdapter before we're prepared.
// Postpone doing anything until we've finished construction.
if (!mPopupSet) {
mTempAdapter = adapter;
return;
}
super.setAdapter(adapter);
if (mPopup != null) {
final Context popupContext = mPopupContext == null ? getContext() : mPopupContext;
mPopup.setAdapter(new DropDownAdapter(adapter, popupContext.getTheme()));
}
}
示例9: onStart
import android.widget.SpinnerAdapter; //导入依赖的package包/类
@Override
public void onStart() {
super.onStart();
nodeindex = Config.currentSelectedStation;
SpinnerAdapter spinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item,
IDECFunctions.getStationsNames());
stations_spinner.setAdapter(spinnerAdapter);
stations_spinner.setSelection(nodeindex);
if (input_action_send != null) {
handleFileChosen(input_action_send);
SimpleFunctions.debug("file was chosen");
} else {
SimpleFunctions.debug("File was not chosen, try to do by hand!");
}
}
示例10: getDropDownView
import android.widget.SpinnerAdapter; //导入依赖的package包/类
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
for (ListAdapter piece : getPieces()) {
int size=piece.getCount();
if (position<size) {
return(((SpinnerAdapter)piece).getDropDownView(position,
convertView,
parent));
}
position-=size;
}
return(null);
}
示例11: updateGroupSpinner
import android.widget.SpinnerAdapter; //导入依赖的package包/类
private void updateGroupSpinner() {
AppUserConfigurationHandler handler = getComponent(AppUserConfigurationHandler.KEY);
if (handler == null) {
Log.e(TAG, "Container not connected!");
return;
}
Set<Group> allGroups = handler.getAllGroups();
if (allGroups.size() < 1) {
Log.i(TAG, "No groups available, yet.");
return;
}
this.groups = Lists.newArrayList(Iterables.transform(allGroups, new Function<Group, String>() {
@Override
public String apply(Group input) {
return input.getName();
}
}));
SpinnerAdapter adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, groups);
spinner.setAdapter(adapter);
spinner.setEnabled(true);
}
示例12: setAdapter
import android.widget.SpinnerAdapter; //导入依赖的package包/类
public void setAdapter(SpinnerAdapter paramSpinnerAdapter)
{
if (!this.mPopupSet) {
this.mTempAdapter = paramSpinnerAdapter;
}
do
{
return;
super.setAdapter(paramSpinnerAdapter);
} while (this.mPopup == null);
if (this.mPopupContext == null) {}
for (Context localContext = getContext();; localContext = this.mPopupContext)
{
this.mPopup.setAdapter(new DropDownAdapter(paramSpinnerAdapter, localContext.getTheme()));
return;
}
}
示例13: onCreate
import android.widget.SpinnerAdapter; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery_2);
// Get a cursor with all people
Cursor c = getContentResolver().query(Contacts.CONTENT_URI,
CONTACT_PROJECTION, null, null, null);
startManagingCursor(c);
SpinnerAdapter adapter = new SimpleCursorAdapter(this,
// Use a template that displays a text view
android.R.layout.simple_gallery_item,
// Give the cursor to the list adatper
c,
// Map the NAME column in the people database to...
new String[] {Contacts.DISPLAY_NAME},
// The "text1" view defined in the XML template
new int[] { android.R.id.text1 });
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(adapter);
}
示例14: shouldVerifyOnCreate_initSpinner
import android.widget.SpinnerAdapter; //导入依赖的package包/类
@Test
public void shouldVerifyOnCreate_initSpinner() {
List<EnvironmentModel> environments = Arrays.
asList(newEnvironment(100, "env1"), newEnvironment(101, "env2"));
List<GatewayModel> gateways = Arrays.
asList(newGateway("uuid1", "1.1.1.1", 1), newGateway("uuid2", "2.2.2.2", 2));
when(environmentService.findAll()).thenReturn(Observable.just(environments));
when(gatewayService.findAll()).thenReturn(Observable.just(gateways));
createWithIntent(null);
SpinnerAdapter adapterEnvironment = spinnerDeviceEnvironment.getAdapter();
assertFalse("should not be empty", adapterEnvironment.isEmpty());
assertEquals("should verify first element", "env1", adapterEnvironment.getItem(0));
assertEquals("should verify second element", "env2", adapterEnvironment.getItem(1));
assertEquals("should select default", 0, spinnerDeviceEnvironment.getSelectedItemPosition());
SpinnerAdapter adapterGateway = spinnerDeviceGateway.getAdapter();
assertFalse("should not be empty", adapterGateway.isEmpty());
assertEquals("should verify first element", "1.1.1.1:1", adapterGateway.getItem(0));
assertEquals("should verify second element", "2.2.2.2:2", adapterGateway.getItem(1));
assertEquals("should select default", 0, spinnerDeviceGateway.getSelectedItemPosition());
}
示例15: shouldVerifyOnCreate_initSpinner_noResult
import android.widget.SpinnerAdapter; //导入依赖的package包/类
@Test
public void shouldVerifyOnCreate_initSpinner_noResult() {
when(environmentService.findAll()).thenReturn(Observable.just(new ArrayList<>()));
when(gatewayService.findAll()).thenReturn(Observable.just(new ArrayList<>()));
createWithIntent(null);
SpinnerAdapter adapterEnvironment = spinnerDeviceEnvironment.getAdapter();
assertFalse("should not be empty", adapterEnvironment.isEmpty());
assertEquals("should verify first element", labelNone, adapterEnvironment.getItem(0));
SpinnerAdapter adapterGateway = spinnerDeviceGateway.getAdapter();
assertFalse("should not be empty", adapterGateway.isEmpty());
assertEquals("should verify first element", labelMissingGateway, adapterGateway.getItem(0));
verifyInitSpinnerSoundType();
}