private void setMineralLists(Sector sector) { // Populate the list with the initial data // Remove the ones we don't want mineralList.clear(); mineralList.addAll(Static.mineralList); // Grab the ore list for later ArrayAdapter<String> oreListAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, new ArrayList<String>()); ((ListView) findViewById(R.id.oreList)).setAdapter(oreListAdapter); // Add and remove the needed things from the lists for (Mineral mineral : sector.getMinerals()) { mineralList.remove(mineral.getMineral()); oreListAdapter.add(mineral.getMineral()); } // Check to see if the mineral list is empty. If so add the emtpy mineral if (mineralList.size() == 0) mineralList.add(emptyMineralString); mineralAdapter.notifyDataSetChanged(); oreListAdapter.notifyDataSetChanged(); }
public void mOnClick(View v) { switch (v.getId()) { case R.id.btn3: mItem.clear(); for (int i = 1001; i <= 1003; i++) { mItem.add(Integer.toString(i)); } mAdapter.notifyDataSetChanged(); break; case R.id.btn10: mItem.clear(); for (int i = 1001; i <= 1010; i++) { mItem.add(Integer.toString(i)); } mAdapter.notifyDataSetChanged(); break; case R.id.btnalways: mList.setOverScrollMode(View.OVER_SCROLL_ALWAYS); break; case R.id.btnnever: mList.setOverScrollMode(View.OVER_SCROLL_NEVER); break; case R.id.btnifscroll: mList.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS); break; } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.time_dialog); etxtTime = (EditText) findViewById(R.id.etxtTime); spTimeUnit = (Spinner) findViewById(R.id.spTimeUnit); butConfirm = (Button) findViewById(R.id.butConfirm); butCancel = (Button) findViewById(R.id.butCancel); butConfirm.setText(R.string.set_sleeptimer_label); butCancel.setText(R.string.cancel_label); setTitle(R.string.set_sleeptimer_label); ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>( this.getContext(), android.R.layout.simple_spinner_item, spinnerContent); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spTimeUnit.setAdapter(spinnerAdapter); spTimeUnit.setSelection(DEFAULT_SPINNER_POSITION); butCancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); butConfirm.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { try { long input = readTimeMillis(); onTimeEntered(input); dismiss(); } catch (NumberFormatException e) { e.printStackTrace(); Toast toast = Toast.makeText(context, R.string.time_dialog_invalid_input, Toast.LENGTH_LONG); toast.show(); } } }); etxtTime.addTextChangedListener( new TextWatcher() { @Override public void afterTextChanged(Editable s) { checkInputLength(s.length()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} }); checkInputLength(etxtTime.getText().length()); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settings); saveBoton = (Button) findViewById(R.id.button1); cancelBoton = (Button) findViewById(R.id.button2); et = (EditText) findViewById(R.id.editText1); prefs = getSharedPreferences("preferences", Context.MODE_PRIVATE); et.setText(String.valueOf(prefs.getLong("rad", 100))); spin = (Spinner) findViewById(R.id.spinner1); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.units, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spin.setAdapter(adapter); spin.setOnItemSelectedListener(new MyOnItemSelectedListener()); saveBoton.setOnClickListener(new OnClickSaveListener()); cancelBoton.setOnClickListener(new OnClickCancelListener()); }
@Override public void onCreate(Context ctx) { LinearLayout linearLayout = new LinearLayout(ctx); linearLayout.setOrientation(LinearLayout.VERTICAL); // beds Spinner spinnerTextField = new Spinner(ctx); ArrayAdapter<Integer> aa = new ArrayAdapter<Integer>( ctx, android.R.layout.simple_spinner_item, new Integer[] {1, 2, 3}); aa.setDropDownViewResource(android.R.layout.select_dialog_singlechoice); spinnerTextField.setAdapter(aa); spinnerTextField.setOnItemSelectedListener(bedCountSpinnerItemSelectionListener); // options TableLayout amenitiesLayout = new TableLayout(ctx); amenitiesLayout.setColumnStretchable(0, false); amenitiesLayout.setColumnShrinkable(1, true); Amenity[] ams = Amenity.values(); for (Amenity amenity : ams) { TableRow tableRow = buildAmenityTableRow(ctx, amenity); amenitiesLayout.addView(tableRow); } linearLayout.addView( Utils.buildLabelAndField(ctx, ctx.getString(R.string.beds_label), spinnerTextField)); linearLayout.addView( Utils.buildLabelAndField(ctx, ctx.getString(R.string.amenities_label), amenitiesLayout)); addView(linearLayout); }
private void setUpSpinnerAdapters() { ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.currencies, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); currency1Spinner.setAdapter(adapter); currency2Spinner.setAdapter(adapter); currency2Spinner.setSelection(1); }
private void initConditions(Context context) { slog.p(TAG, "initConditions geologyIndex " + geologyIndex); ArrayList<String> str = createArrayList(bean.geoObjects.get(geologyIndex).conditions); if (adapterCondition != null) { adapterCondition.clear(); adapterCondition.addAll(str); adapterCondition.notifyDataSetChanged(); } else { adapterCondition = new ArrayAdapter<String>(context, getAdapterLayoutID(), str); mSpinnerCondition.setAdapter(adapterCondition); } }
private void initSpinnerGeologyValue(Context context) { slog.p(TAG, "initSpinnerGeologyValue "); ArrayList<String> str = createArrayList(bean.geoObjects); if (adapterGeology != null) { adapterGeology.clear(); adapterGeology.addAll(str); adapterGeology.notifyDataSetChanged(); } else { adapterGeology = new ArrayAdapter<String>(context, getAdapterLayoutID(), str); mSpinnerGeology.setAdapter(adapterGeology); mSpinnerGeology.setSelection(geologyIndex); } }
private void setupSpinner(Spinner spinner, int optionResourceId, int defaultSelection) { Context context = getContext(); if (context != null) { ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( context, optionResourceId, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(R.layout.spinner_centered_wrapped); spinner.setGravity(Gravity.CENTER); spinner.setAdapter(adapter); spinner.setSelection(defaultSelection); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.blackmagicactivity_layout); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(getString(R.string.hack_login)); username = (EditText) findViewById(R.id.username); password = (EditText) findViewById(R.id.password); spinner = (Spinner) findViewById(R.id.spinner); SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource( this, R.array.tail, android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(mSpinnerAdapter); spinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String[] array = getResources().getStringArray(R.array.tail_value); String value = array[position]; appkey = value.substring(0, value.indexOf(",")); appSecret = value.substring(value.indexOf(",") + 1); } @Override public void onNothingSelected(AdapterView<?> parent) {} }); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { Utility.showLog(TAG, "onLoadFinished"); bookList = getListFromCursor(cursor, bookList); bookArrayAdapter.notifyDataSetChanged(); }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (null != mListener) { Debtor debtor = (Debtor) mAdapter.getItem(position); mListener.onFragmentInteractionNewTransaction( null, null, debtor.getIdAsString(), debtor.getName()); } }
public void clearNumbers(View view) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); listItems.clear(); adapter.notifyDataSetChanged(); Editor editor = sharedPreferences.edit(); editor.clear(); editor.commit(); }
@Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (null != mListener) { Debtor debtor = (Debtor) mAdapter.getItem(position); mListener.onFragmentInteractionEdit( debtor.getIdAsString(), MyOnFragmentInteractionListener.ACTION_EDIT_DEBTOR); } return false; }
private void loadAllBooks() { bookList.clear(); Cursor cursor = DbHelper.getInstance(getApplicationContext()) .getEntry(DbHelper.TABLE_BOOK, mAllBookColumns, null, null, null, null, null); Utility.showLog(TAG, "Total row in cursor:" + cursor.getCount()); bookList = getListFromCursor(cursor, bookList); bookArrayAdapter.notifyDataSetChanged(); }
@Override public void onStart() { super.onStart(); if (D) Log.d(TAG, "++ ON START ++"); if (!mBluetoothAdapter.isEnabled()) { // ask the user to enable BlueTooth Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); } else { // this only works if you already bonded with this device if (D) Log.d(TAG, "BT already enabled"); final BluetoothDevice[] bondedDevices = new BluetoothDevice[mBluetoothAdapter.getBondedDevices().size()]; mBluetoothAdapter.getBondedDevices().toArray(bondedDevices); List<CharSequence> devices = new ArrayList<CharSequence>(); // update the "Select device" spinner for (BluetoothDevice btd : bondedDevices) { Log.d(TAG, "Found bonded device: " + btd.getName()); devices.add(btd.getName()); } ArrayAdapter spinnerAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, devices); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner selectDeviceSpinner = (Spinner) findViewById(R.id.spinner); selectDeviceSpinner.setAdapter(spinnerAdapter); selectDeviceSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { if (D) Log.d(TAG, "Selected: " + bondedDevices[pos].getName()); btDevice = bondedDevices[pos]; } public void onNothingSelected(AdapterView<?> arg0) {} }); } }
@Override public ArrayAdapter<T> with(T value) { return ArrayAdapter.newArrayWith( this.element1, this.element2, this.element3, this.element4, this.element5, this.element6, value); }
@Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { Log.d(TAG, "onItemClick: position: " + position + ", id: " + id); String item = listAdapter.getItem(position).trim(); if (item.endsWith(" =")) { item = item.substring(0, item.length() - 2); } if (!item.startsWith("no result")) { inputView.append(item); } }
protected void initVideoSpinners() { ArrayAdapter<CharSequence> adapter; // Video parameters spinners frameSizeSpinner = (Spinner) findViewById(R.id.frameSize_spinner); adapter = ArrayAdapter.createFromResource( this, R.array.frame_size_values, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); frameSizeSpinner.setAdapter(adapter); frameSizeSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { String[] frameSizeContainer = frameSizeSpinner.getSelectedItem().toString().split("x", 2); videoWidthOut = Integer.valueOf(frameSizeContainer[0].trim()); videoHeightOut = Integer.valueOf(frameSizeContainer[1].trim()); } @Override public void onNothingSelected(AdapterView<?> adapterView) {} }); videoBitRateSpinner = (Spinner) findViewById(R.id.videoBitRate_spinner); adapter = ArrayAdapter.createFromResource( this, R.array.video_bit_rate_values, android.R.layout.simple_spinner_item); videoBitRateSpinner.setAdapter(adapter); videoBitRateSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { videoBitRateInKBytes = Integer.valueOf(videoBitRateSpinner.getSelectedItem().toString()); } @Override public void onNothingSelected(AdapterView<?> adapterView) {} }); }
private void initConditiontValue(Context context) { slog.p( TAG, "initConditions geologyIndex " + geologyIndex + " conditionIndex " + conditionIndex); ArrayList<Values> arrsys = bean.geoObjects.get(geologyIndex).conditions.get(conditionIndex).values; // ArrayList<String> str = createArrayList(arrsys); ArrayList<String> str = new ArrayList<String>(); getAllChildStr(arrsys, str); if (adapterConditionValue != null) { adapterConditionValue.clear(); adapterConditionValue.addAll(str); adapterConditionValue.notifyDataSetChanged(); } else { adapterConditionValue = new ArrayAdapter<String>(context, getAdapterLayoutID(), str); mSpinnerConditionValue.setAdapter(adapterConditionValue); } }
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); // If it's already paired, skip it, because it's been listed already if (device.getBondState() != BluetoothDevice.BOND_BONDED) { mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); } // When discovery is finished, change the Activity title } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { setProgressBarIndeterminateVisibility(false); setTitle(R.string.select_device); if (mNewDevicesArrayAdapter.getCount() == 0) { String noDevices = getResources().getText(R.string.none_found).toString(); mNewDevicesArrayAdapter.add(noDevices); } } }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.masstab); spinnerFrom = (Spinner) findViewById(R.id.SpinnerFrom); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.weights, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerFrom.setAdapter(adapter); spinnerTo = (Spinner) findViewById(R.id.SpinnerTo); spinnerTo.setAdapter(adapter); final Button button = (Button) findViewById(R.id.Go_Button); button.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { calculate(); } }); }
@Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(this); setContentView(R.layout.main); inputView = (EditText) findViewById(R.id.input_view); inputView.setOnEditorActionListener(this); listAdapter = new ArrayAdapter<String>(this, R.layout.row); listAdapter.setNotifyOnChange(true); resultsView = (ListView) this.findViewById(R.id.results_view); resultsView.setAdapter(listAdapter); resultsView.setOnItemClickListener(this); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to if (requestCode == PICK_CONTACT_REQUEST) { // Make sure the request was successful if (resultCode == RESULT_OK) { // Get the URI that points to the selected contact Uri contactUri = data.getData(); // We only need the NUMBER column, because there will be only one row in the result String[] projection = { ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }; CursorLoader cursorLoader = new CursorLoader(getApplicationContext(), contactUri, projection, null, null, null); Cursor cursor = cursorLoader.loadInBackground(); cursor.moveToFirst(); // Retrieve the phone number from the NUMBER column int numberColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); String number = cursor.getString(numberColumn); int nameColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME); String name = cursor.getString(nameColumn); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); Editor editor = sharedPreferences.edit(); editor.putString(name, number); editor.commit(); if (!listItems.contains(name)) { listItems.add(name); adapter.notifyDataSetChanged(); } // ListView contactList = (ListView) findViewById(R.id.contactView); Log.i(TAG, "Phone number: " + String.valueOf(number)); // Do something with the phone number... } } }
/** super returns uncorrected reflectance. */ public float[] processRange(short[] values, HashMap subset) { float[] refls = super.processRange(values, subset); float[] solzen = null; try { solzen = ((FlatField) solzenAdapter.getData(subset)).getFloats()[0]; } catch (Exception e) { e.printStackTrace(); } for (int k = 0; k < refls.length; k++) { float refl = refls[k]; float solz = solzen[k]; if (solz < 88f) { refls[k] = refl / ((float) Math.cos((Math.PI / 180.0) * solz)); } } return refls; }
@Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent); if ((actionId == EditorInfo.IME_ACTION_DONE) || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) { Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER"); String input = textView.getText().toString().trim(); if (input.length() > 0) { String result = ""; try { result += calculator.calculate(input); } catch (Exception e) { result = "no result (" + e.getMessage() + ")"; } if (listAdapter.getCount() > 0) { listAdapter.add(""); } listAdapter.add(input + " ="); if (input.indexOf("@") > -1) { listAdapter.add(calculator.getEquation() + " ="); } listAdapter.add(result); listAdapter.notifyDataSetChanged(); inputView.endBatchEdit(); inputView.setText(""); hideKeyboard(); } } return false; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceBundle) { Bundle args = getArguments(); // If position == 0 then Owe, if == 1 then Owed position = args.getInt("pos"); View v; v = inflater.inflate(R.layout.iou_info_edit_frag, container, false); // Find Views by id confirm = (Button) v.findViewById(R.id.iou_editconfirm); cancel = (Button) v.findViewById(R.id.iou_deletecancel); close = (ImageButton) v.findViewById(R.id.owe_done_button); date = (TextView) v.findViewById(R.id.owe_info_date); name = (TextView) v.findViewById(R.id.owe_dialog_name); amount = (TextView) v.findViewById(R.id.owe_dialog_amount); desc = (TextView) v.findViewById(R.id.owe_description); spinner = (Spinner) v.findViewById(R.id.add_subt_spinner); editBox = (LinearLayout) v.findViewById(R.id.edit_layout); // Set up Spinner Values ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( getActivity(), R.array.add_subt_array, R.layout.spinner_item); adapter.setDropDownViewResource(R.layout.spinner_dropdown); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { add = true; } else { add = false; } } @Override public void onNothingSelected(AdapterView<?> parent) { // To change body of implemented methods use File | Settings | File Templates. } }); // Set the TextViews name.setText(args.getString("name")); amount.setText(String.valueOf(args.getDouble("amount"))); if (args.getString("desc").length() != 0) { desc.setText(args.getString("desc")); } else { desc.setText("None"); } date.setText(args.getString("date")); confirm.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { editBox.setVisibility(View.VISIBLE); } }); return v; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_automation); mUri = null; mDescriptionShoppingList = "?"; mSpinnerAction = (Spinner) findViewById(R.id.spinner_action); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.automation_actions, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinnerAction.setAdapter(adapter); mSpinnerAction.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mDescriptionAction = getResources().getStringArray(R.array.automation_actions)[position]; updateTextViews(); } @Override public void onNothingSelected(AdapterView<?> parent) {} }); mButtonCountdown = (Button) findViewById(R.id.button_list); mButtonCountdown.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { pickList(); } }); mButtonOk = (Button) findViewById(R.id.button_ok); mButtonOk.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { doOk(); } }); mButtonOk.setEnabled(false); Button b = (Button) findViewById(R.id.button_cancel); b.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { doCancel(); } }); mTextCommand = (TextView) findViewById(R.id.command); // mTextSelectAction = (TextView) findViewById(R.id.select_action); // mTextSelectCountdown = (TextView) // findViewById(R.id.select_countdown); if (savedInstanceState != null) { if (savedInstanceState.containsKey(BUNDLE_ACTION)) { int i = savedInstanceState.getInt(BUNDLE_ACTION); mSpinnerAction.setSelection(i); } if (savedInstanceState.containsKey(BUNDLE_LIST_URI)) { mUri = Uri.parse(savedInstanceState.getString(BUNDLE_LIST_URI)); setListNameFromUri(); } } else { final Intent intent = getIntent(); if (intent != null) { String action = intent.getStringExtra(ShoppingListIntents.EXTRA_ACTION); if (ShoppingListIntents.TASK_CLEAN_UP_LIST.equals(action)) { mSpinnerAction.setSelection(0); } else { // set default mSpinnerAction.setSelection(0); } // Get list: final String dataString = intent.getStringExtra(ShoppingListIntents.EXTRA_DATA); if (dataString != null) { mUri = Uri.parse(dataString); } setListNameFromUri(); } } updateTextViews(); }
@Override public void onSearch(String search) { mAdapter.getFilter().filter(search); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.zip_picker); LoggerManager.setLoggerFactory(new AndroidLoggerFactory()); logger = (AndroidLogger) LoggerManager.getLogger(this.getClass().getName()); // enable toasts for info level logging. toasts are default for error and warnings. logger.setToastContext(getBaseContext()); logger.setInfoToastEnabled(true); Button createButton = (Button) findViewById(R.id.SignButton); createButton.setOnClickListener( new OnClickListener() { public void onClick(View view) { invokeZipSignerActivity(); } }); String extStorageDir = Environment.getExternalStorageDirectory().toString(); // Strip /mnt from /sdcard if (extStorageDir.startsWith("/mnt/sdcard")) extStorageDir = extStorageDir.substring(4); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String inputFile = prefs.getString(PREFERENCE_IN_FILE, extStorageDir + "/unsigned.zip"); String outputFile = prefs.getString(PREFERENCE_OUT_FILE, extStorageDir + "/signed.zip"); int keyIndex = prefs.getInt(PREFERENCE_KEY_INDEX, 0); EditText inputText = (EditText) findViewById(R.id.InFileEditText); inputText.setText(inputFile); EditText outputText = (EditText) findViewById(R.id.OutFileEditText); outputText.setText(outputFile); Button button = (Button) findViewById(R.id.OpenPickButton); button.setOnClickListener( new View.OnClickListener() { public void onClick(View arg0) { pickInputFile(); } }); button = (Button) findViewById(R.id.SaveAsPickButton); button.setOnClickListener( new View.OnClickListener() { public void onClick(View arg0) { pickOutputFile(); } }); button = (Button) findViewById(R.id.InOutPickButton); button.setOnClickListener( new View.OnClickListener() { public void onClick(View arg0) { pickInputOutputFiles(); } }); Spinner spinner = (Spinner) findViewById(R.id.KeyModeSpinner); keyModeSpinnerAdapter = KeyListSpinnerAdapter.createInstance(this, android.R.layout.simple_spinner_item); keyModeSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(keyModeSpinnerAdapter); if (keyIndex >= keyModeSpinnerAdapter.getCount()) keyIndex = 0; spinner.setSelection(keyIndex); spinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { SharedPreferences.Editor editor = prefs.edit(); editor.putInt(PREFERENCE_KEY_INDEX, position); editor.commit(); updateAlgorithmSpinner(position); } @Override public void onNothingSelected(AdapterView<?> adapter) {} }); algorithmSpinner = (Spinner) findViewById(R.id.CertSignatureAlgorithm); sha1WithRsaSpinnerAdapter = ArrayAdapter.createFromResource( this, R.array.Sha1WithRsaAlgorithmArray, android.R.layout.simple_spinner_item); sha1WithRsaSpinnerAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); allAlgorithmsSpinnerAdapter = ArrayAdapter.createFromResource( this, R.array.AllShaWithRsaAlgorithmsArray, android.R.layout.simple_spinner_item); allAlgorithmsSpinnerAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); updateAlgorithmSpinner(keyIndex); algorithmSpinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { if (algorithmSpinnerAdapter.getCount() > 1) { SharedPreferences.Editor editor = prefs.edit(); editor.putInt(PREFERENCE_ALG_INDEX, position); editor.commit(); } } @Override public void onNothingSelected(AdapterView<?> adapter) {} }); }