List of usage examples for android.widget TextView setGravity
public void setGravity(int gravity)
From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java
/** * Warning dialog when failed to connect ) (retry function connectSendData()) *///from ww w .j av a2 s . c o m private void showDialog() { progress.show(); android.support.v7.app.AlertDialog.Builder dialog = new android.support.v7.app.AlertDialog.Builder(this); dialog.setMessage(Message.MESSAGE_NETWORK_ERR).setCancelable(false) .setPositiveButton(MESSAGE_RETRY, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { connectSendData(); } }).setNegativeButton(MESSAGE_CANCEL, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); progress.dismiss(); showDialogInfoPathSaveCSV(); //Enable scan isEnableScan = true; registerLicenseCommon.EnableOCROrJanCode(flagSwitchOCR, hsmDecoder); } }); android.support.v7.app.AlertDialog alert = dialog.show(); TextView messageText = (TextView) alert.findViewById(android.R.id.message); assert messageText != null; messageText.setGravity(Gravity.CENTER); }
From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java
/** * Show warning dialog when send data/* www.ja v a 2 s. c o m*/ */ private void showDialogWarningSendData() { progress.show(); AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setMessage(MESSAGE_CONFIRM_SEND_DATA).setCancelable(false) .setPositiveButton(MESSAGE_NO, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); progress.dismiss(); btnSend.setEnabled(true); isEnableScan = true; registerLicenseCommon.EnableOCROrJanCode(flagSwitchOCR, hsmDecoder); } }).setNegativeButton(MESSAGE_YES, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_SEND_DATA); // print log end process LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END); // print log send file data LogManagerCommon.i(TAG, Message.MESSAGE_SEND_DATA); //Save csv and send list file to Bigquery sendData(); } }); AlertDialog alert = dialog.show(); TextView messageText = (TextView) alert.findViewById(android.R.id.message); assert messageText != null; messageText.setGravity(Gravity.CENTER); }
From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java
/** * Show message info list file csv//from w w w . j a v a 2s .c om */ private void showDialogNotifyListCSVWhenLogin() { progress.show(); AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setMessage(MESSAGE_SEND_LIST_FILE_CSV).setCancelable(false) .setPositiveButton(MESSAGE_NO, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); progress.dismiss(); btnSend.setEnabled(true); //Enable scan isEnableScan = true; registerLicenseCommon.EnableOCROrJanCode(flagSwitchOCR, hsmDecoder); } }).setNegativeButton(MESSAGE_YES, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_SEND_DATA); // print log end process LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END); // print log send file data LogManagerCommon.i(TAG, Message.MESSAGE_SEND_DATA); //Send list file csv to bigQuery connectSendDataWhenLogin(); } }); AlertDialog alert = dialog.show(); TextView messageText = (TextView) alert.findViewById(android.R.id.message); assert messageText != null; messageText.setGravity(Gravity.CENTER); }
From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java
/** * Show logout warning dialog/*from w ww . j a v a 2 s . co m*/ */ private void showDialog(boolean isLogout) { progress.show(); AlertDialog.Builder dialog = new AlertDialog.Builder(this); if (isLogout) { dialog.setMessage(MESSAGE_CONFIRM_LOGOUT).setCancelable(false) .setPositiveButton(MESSAGE_YES_JP, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_LOGOUT); // print log end process LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END); // print log move screen LogManagerCommon.i(TAG, String.format(Message.MESSAGE_ACTIVITY_MOVE, Message.SCANNER_ACTIVITY_NAME, Message.LOGIN_ACTIVITY_NAME)); compressFile(); sendFileLog(); } }).setNegativeButton(MESSAGE_NO_JP, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); progress.dismiss(); btnLogout.setEnabled(true); isEnableScan = true; registerLicenseCommon.EnableOCROrJanCode(flagSwitchOCR, hsmDecoder); } }); } else { dialog.setMessage(Message.MESSAGE_NETWORK_ERR).setCancelable(false) .setPositiveButton(MESSAGE_RETRY, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sendFileLog(); } }).setNegativeButton(MESSAGE_CANCEL, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); progress.show(); delete(Constants.STRING_EMPTY); clearAndLogout(); progress.dismiss(); } }); } AlertDialog alert = dialog.show(); TextView messageText = (TextView) alert.findViewById(android.R.id.message); assert messageText != null; messageText.setGravity(Gravity.CENTER); }
From source file:com.cssweb.android.base.QuoteGridActivity.java
private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean) { TextView localTextView = new TextView(this); float f = this.mFontSize; localTextView.setTextSize(f);//from w ww. ja va2s .co m //??4? if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) { if (this.mPaint.measureText(paramString) > textWeight) localTextView.setTextSize(13); } if (n2 == paramInt2) { String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString; localTextView.setText(str); } else { localTextView.setText(paramString); } localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); localTextView.setFocusable(paramBoolean); localTextView.setOnClickListener(mClickListener); localTextView.setOnLongClickListener(mLongClickListener); localTextView.setOnTouchListener(this); //touch localTextView.setTag(paramInt2); localTextView.setEnabled(paramBoolean); localTextView.setSingleLine(false); if (paramInt4 == 0 && paramInt3 >= 0) {// localTextView.setGravity(Gravity.CENTER); int i1 = this.residTitleCol; int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(i1); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this)); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } if (paramInt4 != 0 && paramInt3 >= 0) { int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(this.residCol); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residScrollCol[2]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; //localTextView.setWidth(i8+20); } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; //localTextView.setWidth(i8+20); } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residScrollCol[1]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + rowHeight); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } // if ((paramInt3 == j) && (paramInt4 == l)) { // int i13 = this.residTitleScrollCol[l]; // localDrawable = localResources.getDrawable(i13); // localTextView.setTextColor(paramInt1); // localTextView.setBackgroundDrawable(localDrawable); // paramLinearLayout.addView(localTextView); // return; // } }
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void displayArtistInfo(JSONObject j) throws JSONException { if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config);// w w w .j a va 2 s. c om Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString()); //JSONObject j_artist_info = j.getJSONObject("artist"); final String artist_name = j.getString("name"); tArtistName.setText(artist_name); final JSONObject urls = j.optJSONObject("urls"); final JSONArray videos = j.optJSONArray("video"); final JSONArray images = j.optJSONArray("images"); final String msg = artist_name.replaceAll("\\p{Punct}", " ").replaceAll("\\p{Space}", "+"); AsyncHttpClient client = new AsyncHttpClient(); String fmURL = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + msg + "&autocorrect[1]&format=json&api_key=ca4c10f9ae187ebb889b33ba12da7ee9"; Log.i("musicInfo", fmURL); client.get(fmURL, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { String r = new String(responseBody); ArrayList<String> image_urls = new ArrayList<String>(); try { Log.i("musicInfo", "Communicating with LastFM..."); JSONObject json = new JSONObject(r); Log.i("musicInfo", json.toString()); json = json.getJSONObject("artist"); Log.i("musicInfo", json.toString()); JSONArray artist_images = json.optJSONArray("image"); Log.i("musicInfo", artist_images.toString()); for (int i = 0; i < artist_images.length(); i++) { JSONObject j = artist_images.getJSONObject(i); Log.i("musicInfo", j.optString("size")); if (j.optString("size").contains("extralarge")) { image_urls.add(j.optString("#text")); //b.putString("fm_image", j.getString("#text")); //Log.i("musicInfo", j.getString("#text")); break; } } } catch (JSONException e) { e.printStackTrace(); } if (images != null) { for (int i = 0; i < images.length(); i++) { JSONObject image = null; try { image = images.getJSONObject(i); } catch (JSONException e) { e.printStackTrace(); } int width = image.optInt("width", 0); int height = image.optInt("height", 0); String url = image.optString("url", ""); Log.i("musicInfo", i + ": " + url); if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) { //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) { image_urls.add(url); Log.i("musicInfo", "Selected: " + url); //available_images.put(image); } } } int random = (int) (Math.random() * image_urls.size()); final String f_url = image_urls.get(random); Log.i("musicInfo", "Total image#=" + image_urls.size() + " Selected image#=" + random + " " + f_url); if (image_urls.size() > 0) { imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { lLinkList.removeAllViews(); //String attr = fImage.optJSONObject("license").optString("attribution"); //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr)); if (urls != null) { String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url", "twitter_url" }; for (int i = 0; i < jsonName.length; i++) { if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) { Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i])); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); switch (jsonName[i]) { case "official_url": tv.setText("HOME."); break; case "wikipedia_url": tv.setText("WIKI."); break; case "mb_url": tv.setText("Music Brainz."); break; case "lastfm_url": tv.setText("Last FM."); break; case "twitter_url": tv.setText("Twitter."); break; } try { tv.setTag(urls.getString(jsonName[i])); } catch (JSONException e) { e.printStackTrace(); } tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) v.getTag())); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Toast.makeText(getApplicationContext(), "Open the Link...", Toast.LENGTH_SHORT).show(); //finish(); } }); lLinkList.addView(tv); } } } else { TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText("Sorry, No Link Here..."); lLinkList.addView(tv); } if (videos != null) { jVideoArray = videos; mAdapter = new StaggeredViewAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, generateImageData(videos)); //if (mData == null) { mData = generateImageData(videos); //} //mAdapter.clear(); for (JSONObject data : mData) { mAdapter.add(data); } mGridView.setAdapter(mAdapter); } else { } adjBottomColor(((ImageView) view).getDrawable()); } @Override public void onLoadingCancelled(String imageUri, View view) { } }); } else { ArtistImage.setImageResource(R.drawable.lamb_no_image_available); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { } }); }
From source file:com.asksven.betterbatterystats.StatsActivity.java
public Dialog getShareDialog() { final ArrayList<Integer> selectedSaveActions = new ArrayList<Integer>(); AlertDialog.Builder builder = new AlertDialog.Builder(this); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); boolean saveDumpfile = sharedPrefs.getBoolean("save_dumpfile", true); boolean saveLogcat = sharedPrefs.getBoolean("save_logcat", false); boolean saveDmesg = sharedPrefs.getBoolean("save_dmesg", false); if (saveDumpfile) { selectedSaveActions.add(0);// w ww . jav a2 s . co m } if (saveLogcat) { selectedSaveActions.add(1); } if (saveDmesg) { selectedSaveActions.add(2); } //---- LinearLayout layout = new LinearLayout(this); LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(parms); layout.setGravity(Gravity.CLIP_VERTICAL); layout.setPadding(2, 2, 2, 2); final TextView editTitle = new TextView(StatsActivity.this); editTitle.setText(R.string.share_dialog_edit_title); editTitle.setPadding(40, 40, 40, 40); editTitle.setGravity(Gravity.LEFT); editTitle.setTextSize(20); final EditText editDescription = new EditText(StatsActivity.this); LinearLayout.LayoutParams tv1Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); tv1Params.bottomMargin = 5; layout.addView(editTitle, tv1Params); layout.addView(editDescription, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); //---- // Set the dialog title builder.setTitle(R.string.title_share_dialog) .setMultiChoiceItems(R.array.saveAsLabels, new boolean[] { saveDumpfile, saveLogcat, saveDmesg }, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { // If the user checked the item, add it to the // selected items selectedSaveActions.add(which); } else if (selectedSaveActions.contains(which)) { // Else, if the item is already in the array, // remove it selectedSaveActions.remove(Integer.valueOf(which)); } } }) .setView(layout) // Set the action buttons .setPositiveButton(R.string.label_button_share, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { ArrayList<Uri> attachements = new ArrayList<Uri>(); Reference myReferenceFrom = ReferenceStore.getReferenceByName(m_refFromName, StatsActivity.this); Reference myReferenceTo = ReferenceStore.getReferenceByName(m_refToName, StatsActivity.this); Reading reading = new Reading(StatsActivity.this, myReferenceFrom, myReferenceTo); // save as text is selected if (selectedSaveActions.contains(0)) { attachements.add(reading.writeDumpfile(StatsActivity.this, editDescription.getText().toString())); } // save logcat if selected if (selectedSaveActions.contains(1)) { attachements.add(StatsProvider.getInstance().writeLogcatToFile()); } // save dmesg if selected if (selectedSaveActions.contains(2)) { attachements.add(StatsProvider.getInstance().writeDmesgToFile()); } if (!attachements.isEmpty()) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachements); shareIntent.setType("text/*"); startActivity(Intent.createChooser(shareIntent, "Share info to..")); } } }).setNeutralButton(R.string.label_button_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { Reference myReferenceFrom = ReferenceStore.getReferenceByName(m_refFromName, StatsActivity.this); Reference myReferenceTo = ReferenceStore.getReferenceByName(m_refToName, StatsActivity.this); Reading reading = new Reading(StatsActivity.this, myReferenceFrom, myReferenceTo); // save as text is selected if (selectedSaveActions.contains(0)) { reading.writeDumpfile(StatsActivity.this, editDescription.getText().toString()); } // save logcat if selected if (selectedSaveActions.contains(1)) { StatsProvider.getInstance().writeLogcatToFile(); } // save dmesg if selected if (selectedSaveActions.contains(2)) { StatsProvider.getInstance().writeDmesgToFile(); } Snackbar.make(findViewById(android.R.id.content), getString(R.string.info_files_written) + ": " + StatsProvider.getWritableFilePath(), Snackbar.LENGTH_LONG).show(); } catch (Exception e) { Log.e(TAG, "an error occured writing files: " + e.getMessage()); Snackbar.make(findViewById(android.R.id.content), R.string.info_files_write_error, Snackbar.LENGTH_LONG).show(); } } }).setNegativeButton(R.string.label_button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // do nothing } }); return builder.create(); }
From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java
private void setOnClickView(GalleryItemViewTag tag, String message, View.OnClickListener handler) { tag.thumbnailView.setVisibility(View.VISIBLE); tag.loadingView.setVisibility(View.GONE); TextView v = new TextView(GalleryActivity.this); v.setGravity(Gravity.CENTER); v.setText(getSpannedText(message));/*w w w . j av a 2 s.c o m*/ tag.layout.setVisibility(View.VISIBLE); tag.layout.addView(v); v.setOnClickListener(handler); }
From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java
@Override protected void onResume() { super.onResume(); //Event click item detail lvBook.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w. jav a 2s . c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //Disable scan registerLicenseCommon.DisableScan(hsmDecoder); ProductDetailFragment dProductDetailFragment = new ProductDetailFragment(); FragmentManager fm = getSupportFragmentManager(); Bundle bundleItems = new Bundle(); bundleItems.putString(Constants.COLUMN_JAN_CD, arrBookInlist.get(position)[0]); bundleItems.putString(Constants.COLUMN_STOCK_COUNT, arrBookInlist.get(position)[1]); bundleItems.putString(Constants.COLUMN_GOODS_NAME, arrBookInlist.get(position)[2]); bundleItems.putString(Constants.COLUMN_WRITER_NAME, arrBookInlist.get(position)[3]); bundleItems.putString(Constants.COLUMN_PUBLISHER_NAME, arrBookInlist.get(position)[4]); bundleItems.putString(Constants.COLUMN_PRICE, arrBookInlist.get(position)[5]); bundleItems.putString(Constants.COLUMN_FIRST_SUPPLY_DATE, arrBookInlist.get(position)[6]); bundleItems.putString(Constants.COLUMN_LAST_SUPPLY_DATE, arrBookInlist.get(position)[7]); bundleItems.putString(Constants.COLUMN_LAST_SALES_DATE, arrBookInlist.get(position)[8]); bundleItems.putString(Constants.COLUMN_LAST_ORDER_DATE, arrBookInlist.get(position)[9]); bundleItems.putString(Constants.COLUMN_MEDIA_GROUP1_CD, arrBookInlist.get(position)[10]); bundleItems.putString(Constants.COLUMN_MEDIA_GROUP1_NAME, arrBookInlist.get(position)[11]); bundleItems.putString(Constants.COLUMN_MEDIA_GROUP2_CD, arrBookInlist.get(position)[12]); bundleItems.putString(Constants.COLUMN_MEDIA_GROUP2_NAME, arrBookInlist.get(position)[13]); bundleItems.putString(Constants.COLUMN_SALES_DATE, arrBookInlist.get(position)[14]); bundleItems.putString(Constants.COLUMN_YEAR_RANK, arrBookInlist.get(position)[18]); bundleItems.putString(Constants.COLUMN_JOUBI, arrBookInlist.get(position)[19]); bundleItems.putString(Constants.COLUMN_TOTAL_SALES, arrBookInlist.get(position)[20]); bundleItems.putString(Constants.COLUMN_TOTAL_SUPPLY, arrBookInlist.get(position)[21]); bundleItems.putString(Constants.COLUMN_TOTAL_RETURN, arrBookInlist.get(position)[22]); bundleItems.putString(Constants.COLUMN_LOCATION_ID, arrBookInlist.get(position)[23]); bundleItems.putInt(Constants.COLUMN_MAX_YEAR_RANK, maxYearRank.getMaxYearRank()); //put position edit bundleItems.putInt(Constants.POSITION_EDIT_PRODUCT, position); //put flag switch OCR bundleItems.putString(Constants.FLAG_SWITCH_OCR, flagSwitchOCR); dProductDetailFragment.setArguments(bundleItems); dProductDetailFragment.show(fm, null); } }); //Event long press item detail lvBook.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { //Disable scan registerLicenseCommon.DisableScan(hsmDecoder); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(SdmScannerActivity.this); alertDialogBuilder.setMessage( String.format(Message.MESSAGE_CONFIRM_DELETE_JAN_CD, arrBookInlist.get(position)[0])); alertDialogBuilder.setCancelable(false); // Configure alert dialog button alertDialogBuilder.setPositiveButton(Message.MESSAGE_SELECT_YES, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Remove items long press if (arrBookInlist.size() > 0) { LogManagerCommon.i(TAG, String.format(Message.TAG_SCANNER_ACTIVITY_CANCEL, arrBookInlist.get(position)[0])); arrBookInlist.remove(position); // Set data adapter to list view ListViewScanAdapter adapterBook = new ListViewScanAdapter( SdmScannerActivity.this, arrBookInlist); lvBook.setAdapter(adapterBook); } } }); alertDialogBuilder.setNegativeButton(Message.MESSAGE_SELECT_NO, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = alertDialogBuilder.show(); TextView messageText = (TextView) alert.findViewById(android.R.id.message); assert messageText != null; messageText.setGravity(Gravity.CENTER); //Enable scan isEnableScan = true; registerLicenseCommon.EnableOCROrJanCode(flagSwitchOCR, hsmDecoder); return true; } }); }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void onRemoveClick(View view) { try {/* ww w.j ava2s . c om*/ Toast.makeText(this, item, Toast.LENGTH_SHORT).show(); String[] remove = { "rm", "-rf", irpath + item }; try { Process p = Runtime.getRuntime().exec(remove); Log.i("rm", "Waiting... " + irpath + item); p.waitFor(); Log.i("rm", "Done! " + irpath + item); } catch (Exception e) { Log.e("rm", "Failed! " + irpath + item); e.printStackTrace(); } spinner = ((Spinner) findViewById(R.id.spinner)); localArrayList1 = new ArrayList(); localArrayList1.remove(item); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, localArrayList1); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(dataAdapter); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.done)); builder.setMessage(getString(R.string.done_removing) + " " + item + " " + getString(R.string.files)); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); } catch (NullPointerException ex) { ex.printStackTrace(); AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle(getString(R.string.error)); adb.setMessage(getString(R.string.you_need_to_select)); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); adb.show(); } }