use of android.widget.Spinner in project android_frameworks_base by crdroidandroid.
the class ActionBarView method setNavigationMode.
public void setNavigationMode(int mode) {
final int oldMode = mNavigationMode;
if (mode != oldMode) {
switch(oldMode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mListNavLayout != null) {
removeView(mListNavLayout);
}
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null && mIncludeTabs) {
removeView(mTabScrollView);
}
}
switch(mode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mSpinner == null) {
mSpinner = new Spinner(mContext, null, com.android.internal.R.attr.actionDropDownStyle);
mSpinner.setId(com.android.internal.R.id.action_bar_spinner);
mListNavLayout = new LinearLayout(mContext, null, com.android.internal.R.attr.actionBarTabBarStyle);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
params.gravity = Gravity.CENTER;
mListNavLayout.addView(mSpinner, params);
}
if (mSpinner.getAdapter() != mSpinnerAdapter) {
mSpinner.setAdapter(mSpinnerAdapter);
}
mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);
addView(mListNavLayout);
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null && mIncludeTabs) {
addView(mTabScrollView);
}
break;
}
mNavigationMode = mode;
requestLayout();
}
}
use of android.widget.Spinner in project android_frameworks_base by crdroidandroid.
the class SurfaceCompositionMeasuringActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Detect Andromeda devices by having free-form window management feature.
mAndromeda = getPackageManager().hasSystemFeature(PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT);
detectRefreshRate();
// To layouts in parent. First contains list of Surfaces and second
// controls. Controls stay on top.
RelativeLayout rootLayout = new RelativeLayout(this);
rootLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
CustomLayout layout = new CustomLayout(this);
layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
mWidth = rect.right;
mHeight = rect.bottom;
long maxMemoryPerSurface = roundToNextPowerOf2(mWidth) * roundToNextPowerOf2(mHeight) * 4;
// Use 75% of available memory.
int surfaceCnt = (int) ((getMemoryInfo().availMem * 3) / (4 * maxMemoryPerSurface));
if (surfaceCnt < MIN_NUMBER_OF_SURFACES) {
throw new RuntimeException("Not enough memory to allocate " + MIN_NUMBER_OF_SURFACES + " surfaces.");
}
if (surfaceCnt > MAX_NUMBER_OF_SURFACES) {
surfaceCnt = MAX_NUMBER_OF_SURFACES;
}
LinearLayout controlLayout = new LinearLayout(this);
controlLayout.setOrientation(LinearLayout.VERTICAL);
controlLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mMeasureCompositionButton = createButton("Compositor speed.", controlLayout);
mMeasureAllocationButton = createButton("Allocation speed", controlLayout);
String[] pixelFomats = new String[PIXEL_FORMATS.length];
for (int i = 0; i < pixelFomats.length; ++i) {
pixelFomats[i] = getPixelFormatInfo(PIXEL_FORMATS[i]);
}
mPixelFormatSelector = new Spinner(this);
ArrayAdapter<String> pixelFormatSelectorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, pixelFomats);
pixelFormatSelectorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mPixelFormatSelector.setAdapter(pixelFormatSelectorAdapter);
mPixelFormatSelector.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mPixelFormatSelector);
mResultView = new TextView(this);
mResultView.setBackgroundColor(0);
mResultView.setText("Press button to start test.");
mResultView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mResultView);
mSystemInfoView = new TextView(this);
mSystemInfoView.setBackgroundColor(0);
mSystemInfoView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mSystemInfoView);
for (int i = 0; i < surfaceCnt; ++i) {
CustomSurfaceView view = new CustomSurfaceView(this, "Surface:" + i);
// to mark as media overlay.
if (i == 0) {
view.setLayoutParams(new CustomLayout.LayoutParams(0, 0, mWidth, mHeight));
view.setZOrderMediaOverlay(false);
} else {
// Z order of other layers is not predefined so make offset on x and reverse
// offset on y to make sure that surface is visible in any layout.
int x = i;
int y = (surfaceCnt - i);
view.setLayoutParams(new CustomLayout.LayoutParams(x, y, x + mWidth, y + mHeight));
view.setZOrderMediaOverlay(true);
}
view.setVisibility(View.INVISIBLE);
layout.addView(view);
mViews.add(view);
}
rootLayout.addView(layout);
rootLayout.addView(controlLayout);
setContentView(rootLayout);
}
use of android.widget.Spinner in project android_frameworks_base by AOSPA.
the class ActionBarView method setNavigationMode.
public void setNavigationMode(int mode) {
final int oldMode = mNavigationMode;
if (mode != oldMode) {
switch(oldMode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mListNavLayout != null) {
removeView(mListNavLayout);
}
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null && mIncludeTabs) {
removeView(mTabScrollView);
}
}
switch(mode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mSpinner == null) {
mSpinner = new Spinner(mContext, null, com.android.internal.R.attr.actionDropDownStyle);
mSpinner.setId(com.android.internal.R.id.action_bar_spinner);
mListNavLayout = new LinearLayout(mContext, null, com.android.internal.R.attr.actionBarTabBarStyle);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
params.gravity = Gravity.CENTER;
mListNavLayout.addView(mSpinner, params);
}
if (mSpinner.getAdapter() != mSpinnerAdapter) {
mSpinner.setAdapter(mSpinnerAdapter);
}
mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);
addView(mListNavLayout);
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null && mIncludeTabs) {
addView(mTabScrollView);
}
break;
}
mNavigationMode = mode;
requestLayout();
}
}
use of android.widget.Spinner in project android_frameworks_base by AOSPA.
the class PopupWindowVisibility method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.popup_window_visibility);
mFrame = findViewById(R.id.frame);
mHide = (Button) findViewById(R.id.hide);
mHide.setOnClickListener(this);
mShow = (Button) findViewById(R.id.show);
mShow.setOnClickListener(this);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mStrings);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.auto);
textView.setAdapter(autoAdapter);
}
use of android.widget.Spinner in project android_frameworks_base by AOSPA.
the class ScrollingTabContainerView method createSpinner.
private Spinner createSpinner() {
final Spinner spinner = new Spinner(getContext(), null, com.android.internal.R.attr.actionDropDownStyle);
spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
spinner.setOnItemClickListenerInt(this);
return spinner;
}
Aggregations