Java Code Examples for android.widget.Button#setSelected()
The following examples show how to use
android.widget.Button#setSelected() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogFilesActivity.java From RPiCameraViewer with MIT License | 6 votes |
private void loadLogFile(File logFile, int noFileId, Button thisButton, Button otherButton) { // configure the buttons Log.info("load log file: " + logFile.getName()); thisButton.setSelected(true); otherButton.setSelected(false); // display the loading message ArrayList<String> loading = new ArrayList<>(); loading.add(getString(R.string.loading)); ArrayAdapter<String> loadingAdapter = new ArrayAdapter<>(this, R.layout.row_log, loading); listView.setAdapter(loadingAdapter); // load the list asynchronously new LogFileLoader(logFile, noFileId).execute(); }
Example 2
Source File: ECAlertDialog.java From browser with GNU General Public License v2.0 | 5 votes |
public void show() { super.show(); int i = 0; Button btn = null; Iterator<Button> iterator = mButtons.iterator(); while (iterator.hasNext()) { Button button = iterator.next(); if(button.getVisibility() != View.VISIBLE) { continue; } ++i; btn = button; } if (i == 1) { btn.setBackgroundResource(R.drawable.btn_dialog_single); } if (i == 2) { btn.setSelected(true); ((ViewGroup.MarginLayoutParams)(this.mButtons.get(0)).getLayoutParams()).rightMargin = 1; } if (i == 3) { btn.setSelected(true); ((ViewGroup.MarginLayoutParams)(this.mButtons.get(2)).getLayoutParams()).leftMargin = 1; ((ViewGroup.MarginLayoutParams)(this.mButtons.get(0)).getLayoutParams()).rightMargin = 1; } }
Example 3
Source File: MainActivity.java From SelectorDrawable with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button1 = (Button) findViewById(R.id.button1); Drawable drawable1 = SelectorFactory.create(new SelectorShape.SelectorBuilder().normalColor(Color.RED).pressColor(Color.GREEN).disableColor(Color.BLUE).shapeBuilder(new Shape.ShapeBuilder().corner(30)).build()); button1.setBackgroundDrawable(drawable1); Button button2 = (Button) findViewById(R.id.button2); Drawable drawable2 = SelectorFactory.create(new SelectorDrawable.SelectorBuilder().normalDrawable(getResources().getDrawable(R.mipmap.button_normal)).pressDrawable(getResources().getDrawable(R.mipmap.button_press)).build()); button2.setBackgroundDrawable(drawable2); Button button3 = (Button) findViewById(R.id.button3); Drawable drawable3 = new Shape.ShapeBuilder().strokeColor(Color.RED).strokeWidth(4).build().createGradientDrawable(Color.RED); button3.setBackgroundDrawable(drawable3); TextView textView = (TextView) findViewById(R.id.textView); Drawable drawable4 = SelectorFactory.create(new SelectorShape.SelectorBuilder().normalColor(Color.BLUE).pressColor(Color.GRAY).shapeBuilder(new Shape.ShapeBuilder().corner(15)).build()); textView.setBackgroundDrawable(drawable4); Button button5 = (Button) findViewById(R.id.button5); Drawable drawable5 = SelectorFactory.create(new SelectorShape.SelectorBuilder().normalColor(Color.RED).pressColor(Color.GREEN).disableColor(Color.GRAY).shapeBuilder(new Shape.ShapeBuilder().corner(30)).build()); button5.setBackgroundDrawable(drawable5); button5.setEnabled(false); Button button6 = (Button) findViewById(R.id.button_select_0); Drawable drawable6 = SelectorFactory.create(new SelectorShape.SelectorBuilder().normalColor(Color.RED).pressColor(Color.BLUE).selectColor(Color.BLUE).shapeBuilder(new Shape.ShapeBuilder().corner(30)).build()); button6.setBackgroundDrawable(drawable6); button6.setSelected(true); // 用颜色设置按钮 }
Example 4
Source File: ChannelGraphNavigation.java From WiFiAnalyzer with GNU General Public License v3.0 | 5 votes |
private void setSelected(Button button, boolean selected) { if (selected) { button.setBackgroundColor(ContextCompat.getColor(context, R.color.selected)); button.setSelected(true); } else { button.setBackgroundColor(ContextCompat.getColor(context, R.color.background)); button.setSelected(false); } }
Example 5
Source File: MainActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 5 votes |
/** * Clears all graphics from map view and clears all facilities and barriers from service area parameters. */ private void clearRouteAndGraphics(Button addFacilityButton, Button addBarrierButton, List<ServiceAreaFacility> serviceAreaFacilities, GraphicsOverlay facilityOverlay, GraphicsOverlay serviceAreasOverlay, GraphicsOverlay barrierOverlay) { addFacilityButton.setSelected(false); addBarrierButton.setSelected(false); mServiceAreaParameters.clearFacilities(); mServiceAreaParameters.clearPolylineBarriers(); serviceAreaFacilities.clear(); facilityOverlay.getGraphics().clear(); serviceAreasOverlay.getGraphics().clear(); barrierOverlay.getGraphics().clear(); }
Example 6
Source File: X8FrequencyPointController.java From FimiX8-RE with MIT License | 4 votes |
public void setSelectDisenable() { for (Button selected : this.views) { selected.setSelected(false); } }
Example 7
Source File: UserActivity.java From materialup with Apache License 2.0 | 4 votes |
private void updateFollowBtn(Button btn, boolean following) { btn.setText(following ? R.string.action_following : R.string.action_follow); btn.setSelected(following); }
Example 8
Source File: MainActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 4 votes |
/** * Solves the service area task using the facilities and barriers that were added to the map view. * All service areas that are return will be displayed to the map view. */ private void showServiceAreas(List<ServiceAreaFacility> serviceAreaFacilities, GraphicsOverlay barrierOverlay, GraphicsOverlay serviceAreasOverlay, ServiceAreaTask serviceAreaTask, ArrayList<SimpleFillSymbol> fillSymbols, Button addFacilityButton, Button addBarrierButton) { // need at least one facility for the task to work if (!serviceAreaFacilities.isEmpty()) { // un-select add facility and add barrier buttons addFacilityButton.setSelected(false); addBarrierButton.setSelected(false); List<PolylineBarrier> polylineBarriers = new ArrayList<>(); for (Graphic barrierGraphic : barrierOverlay.getGraphics()) { polylineBarriers.add(new PolylineBarrier((Polyline) barrierGraphic.getGeometry())); mServiceAreaParameters.setPolylineBarriers(polylineBarriers); } serviceAreasOverlay.getGraphics().clear(); mServiceAreaParameters.setFacilities(serviceAreaFacilities); // find service areas around facility using parameters that were set ListenableFuture<ServiceAreaResult> result = serviceAreaTask.solveServiceAreaAsync(mServiceAreaParameters); result.addDoneListener(() -> { try { // display all service areas that were found to mapview List<Graphic> graphics = serviceAreasOverlay.getGraphics(); ServiceAreaResult serviceAreaResult = result.get(); for (int i = 0; i < serviceAreaFacilities.size(); i++) { List<ServiceAreaPolygon> polygons = serviceAreaResult.getResultPolygons(i); // could be more than one service area for (int j = 0; j < polygons.size(); j++) { graphics.add(new Graphic(polygons.get(j).getGeometry(), fillSymbols.get(j % 2))); } } } catch (ExecutionException | InterruptedException e) { String error = e.getMessage().contains("Unable to complete operation") ? "Facility not within San Diego area!" + e : "Error getting the service area result: " + e; Log.e(TAG, error); Toast.makeText(this, error, Toast.LENGTH_LONG).show(); } }); } else { Toast.makeText(this, "Must have at least one Facility on the map!", Toast.LENGTH_LONG).show(); } }