private void setDefaultPrice() { Context context = CashSaleSetActivity.this; final SharedPreferences sharedPref = context.getSharedPreferences(Globals.getUserPrefsName(), Context.MODE_PRIVATE); int defaultPrice = sharedPref.getInt(PrefKeys.DEFAULT_PRICE, 0); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle(R.string.default_price) .setSingleChoiceItems( CashSaleSpec.getPrices(), defaultPrice, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition(); SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt(PrefKeys.DEFAULT_PRICE, selectedPosition); editor.commit(); } }) .show(); }
private void onQueryShopsSuccess() { ArrayAdapter<Shop> adapter = new ArrayAdapter<Shop>(this, R.layout.simple_spinner_dropdown_item, mShops); mShopSp.setAdapter(adapter); final SharedPreferences sharedPref = getSharedPreferences(Globals.getUserPrefsName(), Context.MODE_PRIVATE); int defaultShop = sharedPref.getInt(PrefKeys.DEFAULT_SHOP, 0); mShopSp.setSelection(defaultShop, false); mWhichShop = defaultShop; mShopSp.setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mWhichShop = position; } @Override public void onNothingSelected(AdapterView<?> arg0) {} }); WDTQuery.getinstance().queryInterfaceWarehouses(this, this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cash_sale_set_activity); final ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(R.string.cash_sale); actionBar.setDisplayHomeAsUpEnabled(true); mProgressLayout = (RelativeLayout) findViewById(R.id.progress_layout); mContentLayout = (LinearLayout) findViewById(R.id.content_layout); mShopSp = (Spinner) findViewById(R.id.shop_sp); mWarehouseSp = (Spinner) findViewById(R.id.warehouse_sp); mPriceSp = (Spinner) findViewById(R.id.price_sp); mNotRecordCustomerCheck = (CheckBox) findViewById(R.id.not_record_customer_check); mSearchCustomerBtn = (Button) findViewById(R.id.search_customer_btn); mCustomerInfoLayout = (GridLayout) findViewById(R.id.customer_info_layout); mCustomerNameEdit = (EditText) findViewById(R.id.customer_name_edit); mTelEdit = (EditText) findViewById(R.id.tel_edit); mZipCodeEdit = (EditText) findViewById(R.id.zip_code_edit); mToDistrictAddressBtn = (Button) findViewById(R.id.to_district_address_btn); mToDistrictAddressBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(CashSaleSetActivity.this, AddressSelectActivity.class); startActivityForResult(intent, REQUEST_CODE_ADDRESS); } }); mStreetAddressEdit = (EditText) findViewById(R.id.street_address_edit); mEmailEdit = (EditText) findViewById(R.id.email_edit); mNotRecordCustomerCheck.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { showCustomerInfo(!isChecked); } }); mSearchCustomerBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(CashSaleSetActivity.this, SearchCustomerActivity.class); startActivityForResult(intent, REQUEST_CODE_CUSTOMER); } }); Util.initSpinner( this, mPriceSp, R.layout.simple_spinner_dropdown_item, CashSaleSpec.getPrices()); final SharedPreferences sharedPref = getSharedPreferences(Globals.getUserPrefsName(), Context.MODE_PRIVATE); int defaultPrice = sharedPref.getInt(PrefKeys.DEFAULT_PRICE, 0); mPriceSp.setSelection(defaultPrice); Globals.setWhichPrice(defaultPrice); mPriceSp.setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Globals.setWhichPrice(position); } @Override public void onNothingSelected(AdapterView<?> arg0) {} }); if (Globals.getWhichPrice() == -1) { Globals.setWhichPrice(0); } mOkBtn = (Button) findViewById(R.id.ok_btn); WDTQuery.getinstance().queryShops(this, this); }