List of usage examples for android.widget LinearLayout setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java
private void ensureTitle() { if (!TextUtils.isEmpty(titleText) || !TextUtils.isEmpty(messageText)) { LinearLayout titleContainer = new LinearLayout(getActivity()); titleContainer.setOrientation(LinearLayout.VERTICAL); titleContainer.setGravity(Gravity.CENTER); titleContainer.setBackgroundColor(Color.WHITE); titleContainer// w ww .j a va 2 s . c om .setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(56))); if (!TextUtils.isEmpty(titleText)) { TextView title = new TextView(getActivity()); title.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); title.setText(titleText); title.setGravity(Gravity.CENTER_HORIZONTAL); title.setTextColor(COLOR_TITLE); title.getPaint().setFakeBoldText(true); titleContainer.addView(title); } if (!TextUtils.isEmpty(messageText)) { TextView message = new TextView(getActivity()); message.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); message.setGravity(Gravity.CENTER_HORIZONTAL); message.setText(messageText); message.setTextColor(COLOR_TITLE); titleContainer.addView(message); } titleContainer.setClickable(true); titleContainer.setFocusableInTouchMode(true); sheetContainer.addView(titleContainer); sheetContainer.addView(createLine()); } }
From source file:spring16.cs442.com.obtchat_10.BluetoothChatFragment.java
private void selectImage() { final CharSequence[] items = { "Choose Color", "Take Photo", "Choose from Library", "Blue", "Colours", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(BluetoothChatFragment.this); builder.setTitle("Change Background!"); builder.setItems(items, new DialogInterface.OnClickListener() { @Override/*from ww w . j a v a 2 s .c o m*/ public void onClick(DialogInterface dialog, int item) { if (items[item].equals("Choose Color")) { cp.show(); /* On Click listener for the dialog, when the user select the color */ Button okColor = (Button) cp.findViewById(R.id.okColorButton); okColor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* You can get single channel (value 0-255) */ //selectedColorR = cp.getRed(); //selectedColorG = cp.getGreen(); //selectedColorB = cp.getBlue(); /* Or the android RGB Color (see the android Color class reference) */ //selectedColorRGB = cp.getColor(); LinearLayout layout = (LinearLayout) findViewById(R.id.chatFragment); layout.setBackgroundColor(cp.getColor()); cp.dismiss(); } }); } else if (items[item].equals("Take Photo")) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 1888); } else if (items[item].equals("Choose from Library")) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select File"), 79); } else if (items[item].equals("Blue")) { LinearLayout layout = (LinearLayout) findViewById(R.id.chatFragment); layout.setBackgroundDrawable(getResources().getDrawable(R.drawable.background)); } else if (items[item].equals("Colours")) { LinearLayout layout = (LinearLayout) findViewById(R.id.chatFragment); layout.setBackgroundDrawable(getResources().getDrawable(R.drawable.background3)); } else if (items[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:com.cssweb.android.base.QuoteGridActivity.java
public void setSelectRow(int paramInt) throws Exception { LinearLayout localLinearLayout1 = this.mLinerLock; Integer localInteger1 = Integer.valueOf(this.m_nPos); View localView1 = localLinearLayout1.findViewWithTag(localInteger1); if (localView1 != null) { int l = this.residCol; // int l = this.residSelColor; localView1.setBackgroundResource(l); }//w w w . ja v a 2s . c om LinearLayout localLinearLayout2 = this.mLinerLock; Integer localInteger2 = Integer.valueOf(paramInt); View localView2 = localLinearLayout2.findViewWithTag(localInteger2); if (localView2 != null) { int i1 = this.residSelColor; localView2.setBackgroundColor(i1); } LinearLayout localLinearLayout3 = this.mLinerHScroll; Integer localInteger3 = Integer.valueOf(this.m_nPos); LinearLayout localLinearLayout4 = (LinearLayout) localLinearLayout3.findViewWithTag(localInteger3); if (localLinearLayout4 != null) { int i3 = localLinearLayout4.getChildCount(); for (int i = 0; i < i3; i++) { View localView3 = localLinearLayout4.getChildAt(i); int i0 = 0; if (i == i3 - 1) i0 = this.residScrollCol[2]; else if (i == 13) i0 = this.residScrollCol[1]; else if (i % 2 == 0) i0 = this.residScrollCol[0]; else i0 = this.residScrollCol[1]; localView3.setBackgroundResource(i0); } } LinearLayout localLinearLayout5 = this.mLinerHScroll; Integer localInteger4 = Integer.valueOf(paramInt); LinearLayout localLinearLayout6 = (LinearLayout) localLinearLayout5.findViewWithTag(localInteger4); if (localLinearLayout6 != null) { int i4 = this.residSelColor; localLinearLayout6.setBackgroundColor(i4); } int i6 = localLinearLayout6.getChildCount(); for (int i = 0; i < i6; i++) { View localView6 = localLinearLayout6.getChildAt(i); int i10 = this.residSelColor; localView6.setBackgroundColor(i10); } this.m_nPos = paramInt; this.cssStock = list.get(paramInt - 1); }
From source file:com.me.resume.MainActivity.java
/** * View bgcolor// ww w. j a va2 s . c om * @param ll * @param bgcolor */ private void initBgColor(LinearLayout ll, String bgcolor) { try { if (RegexUtil.checkNotNull(bgcolor)) { ll.setBackgroundColor(Color.parseColor(bgcolor)); } } catch (Exception e) { e.printStackTrace(); ll.setBackgroundColor(Color.parseColor("#CC0000")); } }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
private void confirmSendLog() { CommonLogUtil.flushLog(mContext, mGp); mThemeColorList = ThemeUtil.getThemeColorList(getActivity()); createTempLogFile();/*from w w w. ja v a 2 s . com*/ final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.confirm_send_log_dlg); dialog.setCanceledOnTouchOutside(false); LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.confirm_send_log_dlg_title_view); title_view.setBackgroundColor(mThemeColorList.dialog_title_background_color); TextView title = (TextView) dialog.findViewById(R.id.confirm_send_log_dlg_title); title.setTextColor(mThemeColorList.text_color_dialog_title); TextView msg = (TextView) dialog.findViewById(R.id.confirm_send_log_dlg_msg); msg.setTextColor(mThemeColorList.text_color_info); msg.setBackgroundColor(mThemeColorList.dialog_msg_background_color); final Button btn_ok = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_cancel_btn); final Button btn_preview = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_preview); CommonDialog.setDlgBoxSizeLimit(dialog, false); btn_preview.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + mGp.getLogDirName() + "temp_log.txt"), "text/plain"); startActivity(intent); } }); btn_ok.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { sendLogFileToDeveloper(mGp.getLogDirName() + "temp_log.txt"); dialog.dismiss(); } }); btn_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); }
From source file:nz.ac.auckland.lablet.script.components.TextComponent.java
@Override public View createView(Context context, Fragment parent) { ScriptTreeNodeSheetBase.Counter counter = this.component.getCounter("QuestionCounter"); // Note: we have to do this programmatically because findViewById would find the wrong child // items if there is more than one text question. LinearLayout layout = new LinearLayout(context); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); layout.setOrientation(LinearLayout.VERTICAL); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { layout.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color, null)); } else {/*w w w . j a v a 2 s .co m*/ layout.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color)); } TextView textView = new TextView(context); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(android.R.style.TextAppearance_Medium); } else { textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); } question_num = counter.increaseValue(); textView.setText("Q" + question_num + ": " + text); EditText editText = new EditText(context); editText.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); editText.setText(answer); editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { answer = editable.toString(); update(); } }); layout.addView(textView); layout.addView(editText); return layout; }
From source file:org.telegram.ui.ChannelEditTypeActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//from w w w . j av a 2 s . c om public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (donePressed) { return; } if (!isPrivate && ((currentChat.username == null && nameTextView.length() != 0) || (currentChat.username != null && !currentChat.username .equalsIgnoreCase(nameTextView.getText().toString())))) { if (nameTextView.length() != 0 && !lastNameAvailable) { Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); } AndroidUtilities.shakeView(checkTextView, 2, 0); return; } } donePressed = true; String oldUserName = currentChat.username != null ? currentChat.username : ""; String newUserName = isPrivate ? "" : nameTextView.getText().toString(); if (!oldUserName.equals(newUserName)) { MessagesController.getInstance().updateChannelUserName(chatId, newUserName); } finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); fragmentView = new ScrollView(context); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ScrollView scrollView = (ScrollView) fragmentView; scrollView.setFillViewport(true); linearLayout = new LinearLayout(context); scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); if (currentChat.megagroup) { actionBar.setTitle(LocaleController.getString("GroupType", R.string.GroupType)); } else { actionBar.setTitle(LocaleController.getString("ChannelType", R.string.ChannelType)); } LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.VERTICAL); linearLayout2.setElevation(AndroidUtilities.dp(2)); linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell1 = new RadioButtonCell(context); radioButtonCell1.setElevation(0); radioButtonCell1.setBackgroundResource(R.drawable.list_selector); if (currentChat.megagroup) { radioButtonCell1.setTextAndValue(LocaleController.getString("MegaPublic", R.string.MegaPublic), LocaleController.getString("MegaPublicInfo", R.string.MegaPublicInfo), !isPrivate, false); } else { radioButtonCell1.setTextAndValue(LocaleController.getString("ChannelPublic", R.string.ChannelPublic), LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), !isPrivate, false); } linearLayout2.addView(radioButtonCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isPrivate) { return; } isPrivate = false; updatePrivatePublic(); } }); radioButtonCell2 = new RadioButtonCell(context); radioButtonCell2.setElevation(0); radioButtonCell2.setForeground(R.drawable.list_selector); if (currentChat.megagroup) { radioButtonCell2.setTextAndValue(LocaleController.getString("MegaPrivate", R.string.MegaPrivate), LocaleController.getString("MegaPrivateInfo", R.string.MegaPrivateInfo), isPrivate, false); } else { radioButtonCell2.setTextAndValue(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate), LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), isPrivate, false); } linearLayout2.addView(radioButtonCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); radioButtonCell2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isPrivate) { return; } isPrivate = true; updatePrivatePublic(); } }); sectionCell = new ShadowSectionCell(context); linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); linkContainer = new LinearLayout(context); linkContainer.setOrientation(LinearLayout.VERTICAL); linkContainer.setElevation(AndroidUtilities.dp(2)); linkContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(linkContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); headerCell = new HeaderCell(context); headerCell.setElevation(0); headerCell.setBackground(null); linkContainer.addView(headerCell); publicContainer = new LinearLayout(context); publicContainer.setOrientation(LinearLayout.HORIZONTAL); linkContainer.addView(publicContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 17, 7, 17, 0)); EditText editText = new EditText(context); editText.setText("telegram.me/"); editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); //editText.setHintTextColor(0xff979797); editText.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); editText.setMaxLines(1); editText.setLines(1); editText.setEnabled(false); editText.setBackgroundDrawable(null); editText.setPadding(0, 0, 0, 0); editText.setSingleLine(true); editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); publicContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36)); nameTextView = new EditText(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); if (!isPrivate) { nameTextView.setText(currentChat.username); } //nameTextView.setHintTextColor(0xff979797); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); nameTextView.setMaxLines(1); nameTextView.setLines(1); nameTextView.setBackgroundDrawable(null); nameTextView.setPadding(0, 0, 0, 0); nameTextView.setSingleLine(true); nameTextView.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); nameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE); nameTextView.setHint( LocaleController.getString("ChannelUsernamePlaceholder", R.string.ChannelUsernamePlaceholder)); AndroidUtilities.clearCursorDrawable(nameTextView); publicContainer.addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36)); nameTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { checkUserName(nameTextView.getText().toString()); } @Override public void afterTextChanged(Editable editable) { } }); privateContainer = new TextBlockCell(context); privateContainer.setForeground(R.drawable.list_selector); linkContainer.addView(privateContainer); privateContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (invite == null) { return; } try { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText("label", invite.link); clipboard.setPrimaryClip(clip); Toast.makeText(getParentActivity(), LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT) .show(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); checkTextView = new TextView(context); checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); checkTextView.setVisibility(View.GONE); linkContainer.addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 17, 3, 17, 7)); typeInfoCell = new TextInfoPrivacyCell(context); //typeInfoCell.setBackgroundResource(R.drawable.greydivider_bottom); linearLayout.addView(typeInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); loadingAdminedCell = new LoadingCell(context); linearLayout.addView(loadingAdminedCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); adminedInfoCell = new TextInfoPrivacyCell(context); //adminedInfoCell.setBackgroundResource(R.drawable.greydivider_bottom); linearLayout.addView(adminedInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); updatePrivatePublic(); return fragmentView; }
From source file:de.enlightened.peris.MessageActivity.java
private void renderMessage(final Message message) { final Context context = this.getApplicationContext(); final SharedPreferences appPreferences = context.getSharedPreferences("prefs", 0); final boolean useShading = appPreferences.getBoolean("use_shading", false); final boolean useOpenSans = appPreferences.getBoolean("use_opensans", false); final int fontSize = appPreferences.getInt("font_size", DEFAULT_FONT_SIZE); final boolean currentAvatarSetting = appPreferences.getBoolean("show_images", true); final Typeface opensans = Typeface.createFromAsset(context.getAssets(), "fonts/opensans.ttf"); final View view = this.findViewById(R.id.message_layout); final TextView poAuthor = (TextView) view.findViewById(R.id.message_author); final TextView poTimestamp = (TextView) view.findViewById(R.id.message_timestamp); final TextView tvOnline = (TextView) view.findViewById(R.id.message_online_status); final LinearLayout llBorderBackground = (LinearLayout) view.findViewById(R.id.ll_border_background); final LinearLayout llColorBackground = (LinearLayout) view.findViewById(R.id.ll_color_background); String textColor = context.getString(R.string.default_text_color); if (this.application.getSession().getServer().serverTextColor.contains("#")) { textColor = this.application.getSession().getServer().serverTextColor; }//from w w w.j ava 2s . c o m String boxColor = context.getString(R.string.default_element_background); if (this.application.getSession().getServer().serverBoxColor != null) { boxColor = this.application.getSession().getServer().serverBoxColor; } if (boxColor.contains("#")) { llColorBackground.setBackgroundColor(Color.parseColor(boxColor)); } else { llColorBackground.setBackgroundColor(Color.TRANSPARENT); } //TODO: remove border? String boxBorder = context.getString(R.string.default_element_border); if (this.application.getSession().getServer().serverBoxBorder != null) { boxBorder = this.application.getSession().getServer().serverBoxBorder; } if (boxBorder.contentEquals("1")) { llBorderBackground.setBackgroundResource(R.drawable.element_border); } else { llBorderBackground.setBackgroundColor(Color.TRANSPARENT); } if (useOpenSans) { poAuthor.setTypeface(opensans); poTimestamp.setTypeface(opensans); tvOnline.setTypeface(opensans); } if (useShading) { poAuthor.setShadowLayer(2, 0, 0, Color.parseColor("#66000000")); tvOnline.setShadowLayer(2, 0, 0, Color.parseColor("#66000000")); } final LinearLayout llPostBodyHolder = (LinearLayout) view.findViewById(R.id.message_body_holder); llPostBodyHolder.removeAllViews(); final ImageView poAvatar = (ImageView) view.findViewById(R.id.message_avatar); if (boxColor != null && boxColor.contains("#") && boxColor.length() == 7) { final ImageView postAvatarFrame = (ImageView) view.findViewById(R.id.message_avatar_frame); postAvatarFrame.setColorFilter(Color.parseColor(boxColor)); } else { final ImageView postAvatarFrame = (ImageView) view.findViewById(R.id.message_avatar_frame); postAvatarFrame.setVisibility(View.GONE); } if (message.isAuthorOnline()) { tvOnline.setText("ONLINE"); tvOnline.setVisibility(View.VISIBLE); } else { tvOnline.setVisibility(View.GONE); } poAuthor.setText(message.getAuthor()); poTimestamp.setText(DateTimeUtils.getTimeAgo(message.getTimestamp())); final String postContent = message.getBody(); // TODO: add attachments BBCodeParser.parseCode(context, llPostBodyHolder, postContent, opensans, useOpenSans, useShading, new ArrayList<PostAttachment>(), fontSize, true, textColor, this.application); poAuthor.setTextColor(Color.parseColor(textColor)); poTimestamp.setTextColor(Color.parseColor(textColor)); if (currentAvatarSetting) { if (Net.isUrl(message.getAuthorAvatar())) { final String imageUrl = message.getAuthorAvatar(); ImageLoader.getInstance().displayImage(imageUrl, poAvatar); } else { poAvatar.setImageResource(R.drawable.no_avatar); } } else { poAvatar.setVisibility(View.GONE); } }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
private void initViewWidget() { if (DEBUG_ENABLE) Log.v(APPLICATION_TAG, "initViewWidget"); mDialog.setContentView(R.layout.log_file_list_dlg); ThemeColorList tcl = ThemeUtil.getThemeColorList(getActivity()); final LinearLayout title_view = (LinearLayout) mDialog.findViewById(R.id.log_file_list_dlg_title_view); title_view.setBackgroundColor(tcl.dialog_title_background_color); final TextView dlg_title = (TextView) mDialog.findViewById(R.id.log_file_list_dlg_title); dlg_title.setTextColor(tcl.text_color_dialog_title); dlg_title.setText(mDialogTitle);//from w ww .j a v a 2 s . com final ImageButton dlg_done = (ImageButton) mDialog.findViewById(R.id.log_file_list_dlg_done); dlg_done.setVisibility(ImageButton.GONE); final ListView lv_log_file = (ListView) mDialog.findViewById(R.id.log_file_list_dlg_log_listview); final Button btn_close = (Button) mDialog.findViewById(R.id.log_file_list_dlg_log_close); NotifyEvent ntfy_cb_listener = new NotifyEvent(mContext); ntfy_cb_listener.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { if (mLogFileManagementAdapter.isShowCheckBox()) { // if (mLogFileManagementAdapter.isAnyItemSelected()) { // setContextButtonSelecteMode(mLogFileManagementAdapter); // } else { // setContextButtonNormalMode(mLogFileManagementAdapter); // } setContextButtonSelecteMode(mLogFileManagementAdapter); } }; @Override public void negativeResponse(Context c, Object[] o) { } }); mLogFileManagementAdapter = new CommonLogFileListAdapter(getActivity(), R.layout.log_file_list_item, mLogFileList, ntfy_cb_listener); lv_log_file.setAdapter(mLogFileManagementAdapter); setContextButtonListener(); setContextButtonNormalMode(mLogFileManagementAdapter); final Button btn_save = (Button) mDialog.findViewById(R.id.log_file_list_dlg_log_save); final Button btn_send_dev = (Button) mDialog.findViewById(R.id.log_file_list_dlg_log_send); final CheckBox cb_log_enabled = (CheckBox) mDialog.findViewById(R.id.log_file_list_dlg_log_enabled); btn_save.setEnabled(mGp.isLogEnabled()); btn_send_dev.setEnabled(mGp.isLogEnabled()); cb_log_enabled.setChecked(mGp.isLogEnabled()); cb_log_enabled.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!mDisableChangeLogEnabled) confirmSettingsLogOption(isChecked); mDisableChangeLogEnabled = false; } }); btn_save.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { rotateLogFile(mLogFileManagementAdapter); } }); btn_send_dev.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { confirmSendLog(); } }); lv_log_file.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { if (mLogFileManagementAdapter.getItem(0).log_file_name == null) return; if (mLogFileManagementAdapter.isShowCheckBox()) { mLogFileManagementAdapter .getItem(pos).isChecked = !mLogFileManagementAdapter.getItem(pos).isChecked; mLogFileManagementAdapter.notifyDataSetChanged(); // if (mLogFileManagementAdapter.isAnyItemSelected()) { // setContextButtonSelecteMode(mLogFileManagementAdapter); // } else { // setContextButtonNormalMode(mLogFileManagementAdapter); // } setContextButtonSelecteMode(mLogFileManagementAdapter); } else { showLogFile(mLogFileManagementAdapter, pos); } } }); lv_log_file.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { if (mLogFileManagementAdapter.isEmptyAdapter()) return true; if (!mLogFileManagementAdapter.getItem(pos).isChecked) { if (mLogFileManagementAdapter.isAnyItemSelected()) { int down_sel_pos = -1, up_sel_pos = -1; int tot_cnt = mLogFileManagementAdapter.getCount(); if (pos + 1 <= tot_cnt) { for (int i = pos + 1; i < tot_cnt; i++) { if (mLogFileManagementAdapter.getItem(i).isChecked) { up_sel_pos = i; break; } } } if (pos > 0) { for (int i = pos; i >= 0; i--) { if (mLogFileManagementAdapter.getItem(i).isChecked) { down_sel_pos = i; break; } } } // Log.v("","up="+up_sel_pos+", down="+down_sel_pos); if (up_sel_pos != -1 && down_sel_pos == -1) { for (int i = pos; i < up_sel_pos; i++) mLogFileManagementAdapter.getItem(i).isChecked = true; } else if (up_sel_pos != -1 && down_sel_pos != -1) { for (int i = down_sel_pos + 1; i < up_sel_pos; i++) mLogFileManagementAdapter.getItem(i).isChecked = true; } else if (up_sel_pos == -1 && down_sel_pos != -1) { for (int i = down_sel_pos + 1; i <= pos; i++) mLogFileManagementAdapter.getItem(i).isChecked = true; } mLogFileManagementAdapter.notifyDataSetChanged(); } else { mLogFileManagementAdapter.setShowCheckBox(true); mLogFileManagementAdapter.getItem(pos).isChecked = true; mLogFileManagementAdapter.notifyDataSetChanged(); } setContextButtonSelecteMode(mLogFileManagementAdapter); } return true; } }); btn_close.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mFragment.dismiss(); } }); // CommonDialog.setDlgBoxSizeLimit(mDialog, true); }
From source file:com.retroteam.studio.retrostudio.EditorLandscape.java
/** * Create all the views associated with a track. * @param waveDrawableID/* ww w . j a v a 2s . co m*/ * @param projectLoad * @return */ private ImageView addTrack(int waveDrawableID, boolean projectLoad) { //add the track with the measure adder to the view //get layout LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout); //create track container HorizontalScrollView track_container = new HorizontalScrollView(getApplicationContext()); track_container.setLayoutParams(new HorizontalScrollView.LayoutParams( HorizontalScrollView.LayoutParams.MATCH_PARENT, displaysize.y / 4)); track_container.setBackground(getResources().getDrawable(R.color.track_container_bg)); //create grid layout GridLayout track_grid = new GridLayout(getApplicationContext()); track_grid.setColumnCount(100); track_grid.setRowCount(1); track_grid.setOrientation(GridLayout.HORIZONTAL); track_grid.setId(R.id.track_grid); //create linear layout for track id and wave LinearLayout track_identifier = new LinearLayout(getApplicationContext()); track_identifier.setLayoutParams(new LinearLayout.LayoutParams(displaysize.x / 14, displaysize.y / 4)); track_identifier.setOrientation(LinearLayout.VERTICAL); track_identifier.setBackgroundColor(getResources().getColor(R.color.black_overlay)); //create textview for linear layout TextView track_num = new TextView(getApplicationContext()); track_num.setText("1"); track_num.setTextSize(45); track_num.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL); //create imageview for linear layout ImageView track_type = new ImageView(getApplicationContext()); track_type.setImageResource(waveDrawableID); track_type.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); //create "add measure" for grid layout ImageView add_measure = new ImageView(getApplicationContext()); add_measure.setImageResource(R.drawable.measure_new); add_measure.setLayoutParams(new LinearLayout.LayoutParams((int) (displaysize.x / 3.32), LinearLayout.LayoutParams.MATCH_PARENT)); if (projectLoad) { add_measure.setTag(R.id.TAG_ROW, trackReloadCounter); add_measure.setId(trackReloadCounter + 4200); } else { add_measure.setTag(R.id.TAG_ROW, theproject.size() - 1); add_measure.setId(theproject.size() - 1 + 4200); } add_measure.setTag(R.id.TAG_COLUMN, 0); add_measure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { addMeasure(v, false); } }); track_identifier.addView(track_num); if (projectLoad) { track_num.setText(Integer.toString(trackReloadCounter + 1)); trackReloadCounter += 1; } else { track_num.setText(Integer.toString(theproject.size())); } track_num.setTextSize(45); track_identifier.addView(track_type); track_grid.addView(track_identifier); track_grid.addView(add_measure); track_container.addView(track_grid); track_layout.addView(track_container); return add_measure; }