public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch (item.getItemId()) { case R.id.Edit_Contact: Button b = (Button) findViewById(R.id.button1); b.setVisibility(View.VISIBLE); name.setEnabled(true); name.setFocusableInTouchMode(true); name.setClickable(true); phone.setEnabled(true); phone.setFocusableInTouchMode(true); phone.setClickable(true); email.setEnabled(true); email.setFocusableInTouchMode(true); email.setClickable(true); street.setEnabled(true); street.setFocusableInTouchMode(true); street.setClickable(true); place.setEnabled(true); place.setFocusableInTouchMode(true); place.setClickable(true); return true; case R.id.Delete_Contact: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setMessage(R.string.deleteContact) .setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mydb.deleteContact(id_To_Update); Toast.makeText( getApplicationContext(), "Deleted Successfully", Toast.LENGTH_SHORT) .show(); Intent intent = new Intent(getApplicationContext(), com.example.myapp.MainActivity.class); startActivity(intent); } }) .setNegativeButton( R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); AlertDialog d = builder.create(); d.setTitle("Are you sure"); d.show(); return true; default: return super.onOptionsItemSelected(item); } }
private void init(Context context) { inflater = LayoutInflater.from(context); view = inflater.inflate(R.layout.cs_message_about, null); LinearLayout.LayoutParams param_view = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); param_view.leftMargin = DisplayManager.GetInstance().changeWidthSize(30); param_view.rightMargin = DisplayManager.GetInstance().changeWidthSize(30); param_view.topMargin = DisplayManager.GetInstance().changeWidthSize(20); view.setLayoutParams(param_view); version_title = (TextView) view.findViewById(R.id.version_title); version_content = (TextView) view.findViewById(R.id.version_content); help_title = (TextView) view.findViewById(R.id.help_title); help_title.setFocusable(true); help_title.setFocusableInTouchMode(true); help_content = (TextView) view.findViewById(R.id.help_content); version_title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE); version_content.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE); help_title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE); help_content.setTextSize(TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE); version_title.setText("版本信息"); version_content.setText("当前版本:" + Config.GetInstance().getVersionDisplayText()); help_title.setText("使用帮助"); addView(view); setContentData(getHelpContent(Config.OemType.getOemType(Config.GetInstance().getOemType()))); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); textView = new TextView(this); textView.setText("Press keys (if you have some)!"); textView.setOnKeyListener(this); textView.setFocusableInTouchMode(true); textView.requestFocus(); setContentView(textView); }
public void run() { try { populateListData(searchText); textView.setFocusableInTouchMode(true); textView.requestFocus(); InputMethodManager inputMethodManager = (InputMethodManager) ItemChooseActivity.this.getSystemService( ItemChooseActivity.this.INPUT_METHOD_SERVICE); inputMethodManager.showSoftInput(textView, InputMethodManager.SHOW_IMPLICIT); } catch (Exception ex) { ex.printStackTrace(); } }
public MMImageButton(Context paramContext, AttributeSet paramAttributeSet, int paramInt) { super(paramContext, paramAttributeSet, paramInt); paramAttributeSet = new FrameLayout.LayoutParams(-2, -2); gravity = 17; aAF = new ImageView(paramContext); aAF.setLayoutParams(paramAttributeSet); addView(aAF); paramAttributeSet = new FrameLayout.LayoutParams(-2, -2); gravity = 17; ftN = new TextView(paramContext); ftN.setLayoutParams(paramAttributeSet); ftN.setClickable(false); ftN.setFocusable(false); ftN.setFocusableInTouchMode(false); ftN.setTextColor(a.x(paramContext, 2131231259)); addView(ftN); }
private View generateLeftView(final int position) { TextView view = new TextView(mContext); LinearLayout.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); // lp.setMargins(0, 0, 100, 0); view.setLayoutParams(lp); view.setText("item " + position); view.setPadding(10, 30, 10, 30); // view.setBackgroundColor(Color.parseColor("#f2c2c2")); view.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(mContext, "left " + position, Toast.LENGTH_SHORT).show(); } }); view.setFocusable(false); view.setFocusableInTouchMode(false); return view; }
public void notifyDataSetChange() { currentIndex = 0; if (type == 0) { setAutoStart(false); stopFlipping(); clearAnimation(); TitleAdItem item = vInfos.get(currentIndex); tView.setText(item.getMsg()); } else if (type == 1) { tView.setText(vInfos.get(currentIndex).getMsg()); Animation animation = getInAnimation(); if (animation != null) { animation.setAnimationListener( new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { if (currentIndex < (vInfos.size() - 1)) { currentIndex++; } else { currentIndex = 0; } tView.setText(vInfos.get(currentIndex).getMsg()); } public void onAnimationRepeat(Animation animation) {} public void onAnimationEnd(Animation animation) {} }); } this.startFlipping(); setAutoStart(true); } tView.setSingleLine(true); tView.setFocusableInTouchMode(true); tView.setHorizontallyScrolling(true); tView.setEllipsize(TruncateAt.MARQUEE); tView.setMarqueeRepeatLimit(-1); tView.setFocusable(true); tView.requestFocus(); }
private void init(View mRootView) { lstTrailersNames = new ArrayList<String>(); lstTrailersUrl = new ArrayList<String>(); lstReviewsContent = new ArrayList<String>(); adpTrailersUrl = new TrailersAdapter(getContext(), R.layout.list_row, lstTrailersNames); mUtility = new Utility(getContext()); lstTrailers = (ListView) mRootView.findViewById(R.id.lstTrailers); lstTrailers.setAdapter(adpTrailersUrl); mLayout = (LinearLayout) mRootView.findViewById(R.id.lytMovieDetails); mTxtTitle = (TextView) mRootView.findViewById(R.id.txtTitle); mTxtReleaseDate = (TextView) mRootView.findViewById(R.id.txtReleaseDate); mTxtOverview = (TextView) mRootView.findViewById(R.id.txtOverview); mTxtVoteAverage = (TextView) mRootView.findViewById(R.id.txtVoteAverage); mTxtReviews = (TextView) mRootView.findViewById(R.id.txtReviews); mTxtDuration = (TextView) mRootView.findViewById(R.id.txtDuration); imgPoster = (ImageView) mRootView.findViewById(R.id.imgPoster); btnFavorite = (ToggleButton) mRootView.findViewById(R.id.btnFavorite); mBtnShowReviews = (Button) mRootView.findViewById(R.id.btnShowReviews); mBtnShowTrailers = (Button) mRootView.findViewById(R.id.btnShowTrailers); mTxtTitle.setFocusable(true); mTxtTitle.setFocusableInTouchMode(true); }
private void setContentView(View content) { TextView titleView = (TextView) content.findViewById(R.id.title); TextView breadcrumbView = (TextView) content.findViewById(R.id.breadcrumb); TextView descriptionView = (TextView) content.findViewById(R.id.description); titleView.setText(mTitle); breadcrumbView.setText(mBreadcrumb); descriptionView.setText(mDescription); final ImageView iconImageView = (ImageView) content.findViewById(R.id.icon); if (mIconBackgroundColor != Color.TRANSPARENT) { iconImageView.setBackgroundColor(mIconBackgroundColor); } if (AccessibilityHelper.forceFocusableViews(getActivity())) { titleView.setFocusable(true); titleView.setFocusableInTouchMode(true); descriptionView.setFocusable(true); descriptionView.setFocusableInTouchMode(true); breadcrumbView.setFocusable(true); breadcrumbView.setFocusableInTouchMode(true); } if (mIconResourceId != 0) { iconImageView.setImageResource(mIconResourceId); updateViewSize(iconImageView); } else { if (mIconBitmap != null) { iconImageView.setImageBitmap(mIconBitmap); updateViewSize(iconImageView); } else { if (mIconUri != null) { iconImageView.setVisibility(View.INVISIBLE); DrawableDownloader bitmapDownloader = DrawableDownloader.getInstance(content.getContext()); mBitmapCallBack = new BitmapCallback() { @Override public void onBitmapRetrieved(Drawable bitmap) { if (bitmap != null) { mIconBitmap = (bitmap instanceof BitmapDrawable) ? ((BitmapDrawable) bitmap).getBitmap() : null; iconImageView.setVisibility(View.VISIBLE); iconImageView.setImageDrawable(bitmap); updateViewSize(iconImageView); } } }; bitmapDownloader.getBitmap( new BitmapWorkerOptions.Builder(content.getContext()) .resource(mIconUri) .width(iconImageView.getLayoutParams().width) .build(), mBitmapCallBack); } else { iconImageView.setVisibility(View.GONE); } } } content.setTag(R.id.title, titleView); content.setTag(R.id.breadcrumb, breadcrumbView); content.setTag(R.id.description, descriptionView); content.setTag(R.id.icon, iconImageView); }
@Override protected void initData() { titleView.setTitle("确认订单"); Bundle bundle = getIntent().getExtras(); cartList = (List<GoodsCartBean>) bundle.getSerializable("orderList"); quantity = bundle.getInt("quantity", 0); minimum = bundle.getInt("minimum", 0); setMoney(); options = TApplication.getInstance().getAllOptionsNoAmi(R.drawable.bg_defualt_118); ordersAdapter = new CommAdapter<GoodsCartBean>(context, cartList, R.layout.item_sure_order_cart) { @Override public void onGetView(int position, View convertView, final GoodsCartBean cartData) { ImageLoader.getInstance() .displayImage( cartData.image, (ImageView) convertView.findViewById(R.id.cart_pic_img), options); setText(convertView, R.id.item_order_position, "产品" + (position + 1)); setText(convertView, R.id.item_cart_title_tv, cartData.title); setText(convertView, R.id.item_order_quantity, "" + cartData.allQua); setText(convertView, R.id.item_order_price, "¥" + cartData.allPri); AutoSizeListView sukListView = (AutoSizeListView) convertView.findViewById(R.id.item_order_lv); ordersSukAdapter = new CommAdapter<GoodsCartSukBean>( context, cartData.sukList, R.layout.item_sure_order_suk_cart) { @Override public void onGetView( int position, View convertView, final GoodsCartSukBean data) { setText(convertView, R.id.cart_suk_color, "颜色:" + data.colour); setText(convertView, R.id.cart_suk_size, "尺码:" + data.size); setText( convertView, R.id.cart_suk_price, "单价:" + String.format("%.2f", data.preferentialPrice) + "/件"); setText( convertView, R.id.cart_suk_money, "¥" + String.format("%.2f", data.preferentialPrice * data.quantity)); StockChangeView stockCv = (StockChangeView) convertView.findViewById(R.id.cart_suk_change); if (quantity == 0) { stockCv.isChange(false); stockCv.notifyNum(data.quantity, data.detailId); } else { stockCv.isChange(true); stockCv.notifyNum( data.quantity, minimum, quantity, new OnNumChangeListenner() { @Override public void changeNum(int num) { data.quantity = num; setMoney(); } }); } } }; sukListView.setAdapter(ordersSukAdapter); } }; orderLv.setAdapter(ordersAdapter); // 解决ScrollView下嵌套ListView进页面不在顶部的问题 nameTv.setFocusable(true); nameTv.setFocusableInTouchMode(true); nameTv.requestFocus(); }
/** * Called when the activity is first created. * * <p>fetch all settings out of database and prepare view for users.\n if save button is pressed, * all settings are fetched out of view and saved in the database. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settingsmenu); dbHelper = new DataBaseHelper(getApplicationContext()); dbHelper.openDataBase(); boxTemp = (CheckBox) findViewById(R.id.checkBoxTemp); boxPres = (CheckBox) findViewById(R.id.checkBoxPres); boxHum = (CheckBox) findViewById(R.id.checkBoxHum); boxOwn1 = (CheckBox) findViewById(R.id.checkBoxOwn1); boxOwn2 = (CheckBox) findViewById(R.id.checkBoxOwn2); jsonTemp = (EditText) findViewById(R.id.editTextjson1); jsonPres = (EditText) findViewById(R.id.editTextjson2); jsonHum = (EditText) findViewById(R.id.editTextjson3); jsonOwn1 = (EditText) findViewById(R.id.editTextjson4); jsonOwn2 = (EditText) findViewById(R.id.editTextjson5); jsonOwn1_scale = (EditText) findViewById(R.id.editTextjson4_scale); jsonOwn2_scale = (EditText) findViewById(R.id.editTextjson5_scale); TextView text = (TextView) findViewById(R.id.topText); text.setFocusable(true); text.setFocusableInTouchMode(true); jsonTemp.setEnabled(false); jsonTemp.setText(R.string.jsonTemperatur); jsonPres.setEnabled(false); jsonPres.setText(R.string.jsonLuftdruck); jsonHum.setEnabled(false); jsonHum.setText(R.string.jsonLuftfeuchtigkeit); if (dbHelper.getSetting(dbHelper.getCheckboxTempID()).equals(TRUE)) boxTemp.setChecked(true); if (dbHelper.getSetting(dbHelper.getCheckboxPresID()).equals(TRUE)) boxPres.setChecked(true); if (dbHelper.getSetting(dbHelper.getCheckboxHumID()).equals(TRUE)) boxHum.setChecked(true); if (dbHelper.getSetting(dbHelper.getCheckboxOwn1ID()).equals(TRUE)) { boxOwn1.setChecked(true); jsonOwn1.setText(dbHelper.getSetting(dbHelper.getJsonOwn1ID())); jsonOwn1_scale.setText(dbHelper.getSetting(dbHelper.getJsonOwn1SCALEID())); } if (dbHelper.getSetting(dbHelper.getCheckboxOwn2ID()).equals(TRUE)) { boxOwn2.setChecked(true); jsonOwn2.setText(dbHelper.getSetting(dbHelper.getJsonOwn2ID())); jsonOwn2_scale.setText(dbHelper.getSetting(dbHelper.getJsonOwn2SCALEID())); } ip = (EditText) findViewById(R.id.editTextIPAddress); http = (EditText) findViewById(R.id.editTextHTTPCall); ip.setText(dbHelper.getSetting(dbHelper.getIpID())); http.setText(dbHelper.getSetting(dbHelper.getHttpID())); Button buttonSave = (Button) findViewById(R.id.save); dbHelper.close(); // Alle Einstellungen werden übernommen, sobald auf Speichern geklickt wird. buttonSave.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dbHelper.openDataBaseRW(); String ipAddr = ip.getText().toString(); if (ipAddr.contains("http://")) ipAddr = ipAddr.replace("http://", ""); String httpCall = http.getText().toString(); dbHelper.setSetting(ipAddr, dbHelper.getIpID()); dbHelper.setSetting(httpCall, dbHelper.getHttpID()); if (boxTemp.isChecked()) dbHelper.setSetting(TRUE, dbHelper.getCheckboxTempID()); else dbHelper.setSetting(FALSE, dbHelper.getCheckboxTempID()); if (boxPres.isChecked()) dbHelper.setSetting(TRUE, dbHelper.getCheckboxPresID()); else dbHelper.setSetting(FALSE, dbHelper.getCheckboxPresID()); if (boxHum.isChecked()) dbHelper.setSetting(TRUE, dbHelper.getCheckboxHumID()); else dbHelper.setSetting(FALSE, dbHelper.getCheckboxHumID()); if (boxOwn1.isChecked()) { dbHelper.setSetting(TRUE, dbHelper.getCheckboxOwn1ID()); dbHelper.setSetting(jsonOwn1.getText().toString(), dbHelper.getJsonOwn1ID()); dbHelper.setSetting( jsonOwn1_scale.getText().toString(), dbHelper.getJsonOwn1SCALEID()); } else { dbHelper.setSetting(FALSE, dbHelper.getCheckboxOwn1ID()); dbHelper.setSetting(jsonOwn1.getText().toString(), dbHelper.getJsonOwn1ID()); dbHelper.setSetting( jsonOwn1_scale.getText().toString(), dbHelper.getJsonOwn1SCALEID()); } if (boxOwn2.isChecked()) { dbHelper.setSetting(TRUE, dbHelper.getCheckboxOwn2ID()); dbHelper.setSetting(jsonOwn2.getText().toString(), dbHelper.getJsonOwn2ID()); dbHelper.setSetting( jsonOwn2_scale.getText().toString(), dbHelper.getJsonOwn2SCALEID()); } else { dbHelper.setSetting(FALSE, dbHelper.getCheckboxOwn2ID()); dbHelper.setSetting(jsonOwn2.getText().toString(), dbHelper.getJsonOwn2ID()); dbHelper.setSetting( jsonOwn2_scale.getText().toString(), dbHelper.getJsonOwn2SCALEID()); } dbHelper.close(); Toast.makeText( getApplicationContext(), getString(R.string.toastSaved), Toast.LENGTH_LONG) .show(); // TODO: redirect to Mainpage or graphview } }); }
/** Formats message as a View suitable for a conversation list */ private View oneMessageToView(ConversationOneMessage oMsg) { final String method = "oneMessageToView"; if (MyLog.isLoggable(this, MyLog.VERBOSE)) { MyLog.v( this, method + ": msgId=" + oMsg.msgId + (oMsg.avatarDrawable != null ? ", avatar=" + oMsg.avatarDrawable.getFileName() : "")); } LayoutInflater inflater = LayoutInflater.from(context); int layoutResource = R.layout.message_conversation; if (!Activity.class.isAssignableFrom(context.getClass())) { MyLog.w(this, "Context should be from an Activity"); } View messageView = inflater.inflate(layoutResource, null); messageView.setOnCreateContextMenuListener(contextMenu); float displayDensity = context.getResources().getDisplayMetrics().density; // See // http://stackoverflow.com/questions/2238883/what-is-the-correct-way-to-specify-dimensions-in-dip-from-java-code int indent0 = (int) (10 * displayDensity); int indentPixels = indent0 * oMsg.indentLevel; LinearLayout messageIndented = (LinearLayout) messageView.findViewById(R.id.message_indented); if (oMsg.msgId == selectedMessageId && oMsgs.size() > 1) { messageIndented.setBackgroundDrawable( context.getResources().getDrawable(R.drawable.message_current_background)); } int viewToTheLeftId = 0; if (oMsg.indentLevel > 0) { View divider = messageView.findViewById(R.id.divider); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1); layoutParams.leftMargin = indentPixels - 4; divider.setLayoutParams(layoutParams); if (MyLog.isLoggable(this, MyLog.VERBOSE)) { MyLog.v(this, "density=" + displayDensity); } viewToTheLeftId = 2; ImageView indentView = new ConversationIndentImageView(context, messageIndented, indentPixels); indentView.setId(viewToTheLeftId); ((ViewGroup) messageIndented.getParent()).addView(indentView); } if (MyPreferences.showAvatars()) { ImageView avatarView = new ImageView(context); int size = Math.round(AvatarDrawable.AVATAR_SIZE_DIP * displayDensity); avatarView.setScaleType(ScaleType.FIT_CENTER); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(size, size); layoutParams.topMargin = 3; if (oMsg.indentLevel > 0) { layoutParams.leftMargin = 1; } if (viewToTheLeftId == 0) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); } else { layoutParams.addRule(RelativeLayout.RIGHT_OF, viewToTheLeftId); } avatarView.setLayoutParams(layoutParams); avatarView.setImageDrawable(oMsg.avatarDrawable.getDrawable()); indentPixels += size; ((ViewGroup) messageIndented.getParent()).addView(avatarView); } messageIndented.setPadding(indentPixels + 6, 2, 6, 2); TextView id = (TextView) messageView.findViewById(R.id.id); id.setText(Long.toString(oMsg.msgId)); TextView linkedUserId = (TextView) messageView.findViewById(R.id.linked_user_id); linkedUserId.setText(Long.toString(oMsg.linkedUserId)); TextView author = (TextView) messageView.findViewById(R.id.message_author); TextView body = (TextView) messageView.findViewById(R.id.message_body); TextView details = (TextView) messageView.findViewById(R.id.message_details); author.setText(oMsg.author); TextView number = (TextView) messageView.findViewById(R.id.message_number); number.setText(Integer.toString(oMsg.historyOrder)); if (!TextUtils.isEmpty(oMsg.body)) { body.setLinksClickable(true); body.setMovementMethod(LinkMovementMethod.getInstance()); body.setFocusable(true); body.setFocusableInTouchMode(true); Spanned spanned = Html.fromHtml(oMsg.body); body.setText(spanned); if (!MbMessage.hasUrlSpans(spanned)) { Linkify.addLinks(body, Linkify.ALL); } } // Everything else goes to messageDetails String messageDetails = RelativeTime.getDifference(context, oMsg.createdDate); if (!SharedPreferencesUtil.isEmpty(oMsg.via)) { messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context.getText(R.string.message_source_from).toString(), oMsg.via); } if (oMsg.inReplyToMsgId != 0) { String inReplyToName = oMsg.inReplyToName; if (SharedPreferencesUtil.isEmpty(inReplyToName)) { inReplyToName = "..."; } messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context.getText(R.string.message_source_in_reply_to).toString(), oMsg.inReplyToName) + " (" + msgIdToHistoryOrder(oMsg.inReplyToMsgId) + ")"; } if (!SharedPreferencesUtil.isEmpty(oMsg.rebloggersString) && !oMsg.rebloggersString.equals(oMsg.author)) { if (!SharedPreferencesUtil.isEmpty(oMsg.inReplyToName)) { messageDetails += ";"; } messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context .getText(ma.alternativeTermForResourceId(R.string.reblogged_by)) .toString(), oMsg.rebloggersString); } if (!SharedPreferencesUtil.isEmpty(oMsg.recipientName)) { messageDetails += " " + String.format( MyContextHolder.get().getLocale(), context.getText(R.string.message_source_to).toString(), oMsg.recipientName); } if (MyLog.isLoggable(this, MyLog.VERBOSE)) { messageDetails = messageDetails + " (i" + oMsg.indentLevel + ",r" + oMsg.replyLevel + ")"; } details.setText(messageDetails); ImageView favorited = (ImageView) messageView.findViewById(R.id.message_favorited); favorited.setImageResource( oMsg.favorited ? android.R.drawable.star_on : android.R.drawable.star_off); return messageView; }