List of usage examples for android.widget TextView setOnKeyListener
public void setOnKeyListener(OnKeyListener l)
From source file:com.jefftharris.passwdsafe.lib.view.GuiUtils.java
/** * Setup the keyboard on a form. The final field performs the supplied * runnable when enter is pressed./*from w w w .ja v a 2 s. c o m*/ */ public static void setupFormKeyboard(TextView firstField, TextView finalField, Context ctx, final Runnable enterRunnable) { if (firstField != null) { GuiUtilsFroyo.showKeyboard(firstField, ctx); } finalField.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_ENTER: { enterRunnable.run(); return true; } } } return false; } }); }
From source file:fr.eoit.activity.fragment.manufacture.ProductionPlanFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View fragment = inflater.inflate(R.layout.manufacture_production_plan, container, false); Mining.loadMiningData(getActivity(), Mining.ONLY_BASIC_ASTEROIDS); Bundle args = getArguments();// www . j av a2 s. co m itemId = args.getInt("itemId", 0); sellPrice = args.getDouble("sellPrice", 0); producePrice = args.getDouble("producePrice", 0); unitPerBatch = args.getInt("unitPerBatch", 0); baseProductionTime = args.getInt("productionTime", 0); int categorieId = args.getInt("categorieId"); TextView runsTextView = (TextView) fragment.findViewById(R.id.RUNS); runsTextView.setOnKeyListener(new RunsListener()); runsTextView.setText("1"); totalPriceTextView = (TextView) fragment.findViewById(R.id.TOTAL_PROFIT_VALUE); totalTimeTextView = (TextView) fragment.findViewById(R.id.TOTAL_TIME_VALUE); stepsFragments[0] = (EnhancedMaterialListFragment) getFragmentManager() .findFragmentById(R.id.PRODUCTION_STEP0); stepsFragments[1] = (EnhancedMaterialListFragment) getFragmentManager() .findFragmentById(R.id.PRODUCTION_STEP1); stepsFragments[2] = (EnhancedMaterialListFragment) getFragmentManager() .findFragmentById(R.id.PRODUCTION_STEP2); stepsFragments[3] = (EnhancedMaterialListFragment) getFragmentManager() .findFragmentById(R.id.PRODUCTION_STEP3); stepsFragments[4] = (EnhancedMaterialListFragment) getFragmentManager() .findFragmentById(R.id.PRODUCTION_STEP4); stepsFragments[5] = (EnhancedMaterialListFragment) getFragmentManager() .findFragmentById(R.id.PRODUCTION_STEP5); stepsFragments[0].getView().setVisibility(View.GONE); stepsFragments[1].getView().setVisibility(View.GONE); stepsFragments[2].getView().setVisibility(View.GONE); stepsFragments[3].getView().setVisibility(View.GONE); stepsFragments[4].getView().setVisibility(View.GONE); stepsFragments[5].getView().setVisibility(View.GONE); getLoaderManager().initLoader(BASE_PRODUCTION_NEEDS_LOADER_ID, null, new BaseProductionNeedsLoader.BaseProductionNeedsLoaderCallBacks(getActivity(), this, itemId, categorieId)); return fragment; }
From source file:com.dahl.brendan.wordsearch.view.WordSearchActivity.java
/** * creates a grid of textViews from layout files based on the gridSize * and sets the new textViews to use the controller as their listener * /*from ww w. j a v a 2 s . co m*/ * @param gridSize square size of the new grid to make * @param controller the onkeyListener used for the grid's textViews, also holds the gridView an array of the new textView's in the grid */ public void setupViewGrid() { control.setLetter(null); int gridSize = control.getGridSize(); TextViewGridController controller = control.getGridManager(); ViewGroup gridTable = (ViewGroup) this.findViewById(R.id.gridTable); if (gridTable.getChildCount() != gridSize) { if (gridTable.getChildCount() == 0) { gridTable.setKeepScreenOn(true); gridTable.setOnTouchListener(controller); } controller.clearPointDemension(); gridTable.removeAllViews(); Point point = new Point(); controller.setGridView(new TextView[gridSize][]); TextView[][] gridView = controller.getGridView(); for (point.y = 0; point.y < gridSize; point.y++) { this.getLayoutInflater().inflate(R.layout.grid_row, gridTable, true); ViewGroup row = (ViewGroup) gridTable.getChildAt(point.y); TextView[] rowText = new TextView[gridSize]; for (point.x = 0; point.x < gridSize; point.x++) { this.getLayoutInflater().inflate(R.layout.grid_text_view, row, true); TextView view = (TextView) row.getChildAt(point.x); view.setId(ConversionUtil.convertPointToID(point, control.getGridSize())); view.setOnKeyListener(controller); rowText[point.x] = view; } gridView[point.y] = rowText; } gridTable.requestLayout(); } }
From source file:ws.crandell.newspaperpuzzles.wordsearch.view.WordSearchActivity.java
/** * creates a grid of textViews from layout files based on the gridSize * and sets the new textViews to use the controller as their listener * //ww w . j ava2 s .c o m * @param gridSize square size of the new grid to make * @param controller the onkeyListener used for the grid's textViews, also holds the gridView an array of the new textView's in the grid */ public void setupViewGrid() { control.setLetter(null); int gridSize = control.getGridSize(); TextViewGridController controller = control.getGridManager(); ViewGroup gridTable = (ViewGroup) this.findViewById(R.id.gridTable); if (gridTable.getChildCount() != gridSize) { if (gridTable.getChildCount() == 0) { gridTable.setKeepScreenOn(true); gridTable.setOnTouchListener(controller); } controller.clearPointDemension(); gridTable.removeAllViews(); Point point = new Point(); controller.setGridView(new TextView[gridSize][]); TextView[][] gridView = controller.getGridView(); for (point.y = 0; point.y < gridSize; point.y++) { this.getLayoutInflater().inflate(R.layout.ws_grid_row, gridTable, true); ViewGroup row = (ViewGroup) gridTable.getChildAt(point.y); TextView[] rowText = new TextView[gridSize]; for (point.x = 0; point.x < gridSize; point.x++) { this.getLayoutInflater().inflate(R.layout.ws_grid_text_view, row, true); TextView view = (TextView) row.getChildAt(point.x); view.setId(ConversionUtil.convertPointToID(point, control.getGridSize())); view.setOnKeyListener(controller); rowText[point.x] = view; } gridView[point.y] = rowText; } gridTable.requestLayout(); } }
From source file:com.android.launcher3.Hotseat.java
void resetLayout() { mContent.removeAllViewsInLayout();/* ww w . jav a2 s . co m*/ if (!FeatureFlags.NO_ALL_APPS_ICON) { // Add the Apps button Context context = getContext(); int allAppsButtonRank = mLauncher.getDeviceProfile().inv.getAllAppsButtonRank(); LayoutInflater inflater = LayoutInflater.from(context); TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mContent, false); Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon); mLauncher.resizeIconDrawable(d); int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down); Rect bounds = d.getBounds(); d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx, bounds.bottom - scaleDownPx / 2); allAppsButton.setCompoundDrawables(null, d, null, null); allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label)); allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener()); if (mLauncher != null) { mLauncher.setAllAppsButton(allAppsButton); allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener()); allAppsButton.setOnClickListener(mLauncher); allAppsButton.setOnLongClickListener(mLauncher); allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler); } // Note: We do this to ensure that the hotseat is always laid out in the orientation of // the hotseat in order regardless of which orientation they were added int x = getCellXFromOrder(allAppsButtonRank); int y = getCellYFromOrder(allAppsButtonRank); CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1); lp.canReorder = false; mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true); } }