List of usage examples for android.widget TextView setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.roselism.bottomsheet.BottomSheet.java
private void init(final Context context) { setCanceledOnTouchOutside(cancelOnTouchOutside); final ClosableSlidingLayout mDialogView = (ClosableSlidingLayout) View.inflate(context, R.layout.bottom_sheet_dialog, null); LinearLayout mainLayout = (LinearLayout) mDialogView.findViewById(R.id.bs_main); mainLayout.addView(View.inflate(context, mHeaderLayoutId, null), 0); setContentView(mDialogView);//from w w w . java2s . c o m if (!cancelOnSwipeDown) { mDialogView.swipeable = cancelOnSwipeDown; } mDialogView.setSlideListener(new ClosableSlidingLayout.SlideListener() { @Override public void onClosed() { BottomSheet.this.dismiss(); } @Override public void onOpened() { showFullItems(); } }); super.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { if (showListener != null) { showListener.onShow(dialogInterface); } list.setAdapter(adapter); list.startLayoutAnimation(); if (builder.icon == null) { icon.setVisibility(View.GONE); } else { icon.setVisibility(View.VISIBLE); icon.setImageDrawable(builder.icon); } } }); int[] location = new int[2]; mDialogView.getLocationOnScreen(location); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { mDialogView.setPadding(0, location[0] == 0 ? helper.mStatusBarHeight : 0, 0, 0); mDialogView.getChildAt(0).setPadding(0, 0, 0, helper.mNavBarAvailable ? helper.getNavigationBarHeight(getContext()) + mDialogView.getPaddingBottom() : 0); } final TextView title = (TextView) mDialogView.findViewById(R.id.bottom_sheet_title); if (builder.title != null) { title.setVisibility(View.VISIBLE); title.setText(builder.title); // title.setGravity(mHasContent ? Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL // : Gravity.LEFT); // ??? } icon = (ImageView) mDialogView.findViewById(R.id.bottom_sheet_title_image); list = (GridView) mDialogView.findViewById(R.id.bottom_sheet_gridview); mDialogView.mTarget = list; if (!builder.grid) { list.setNumColumns(1); } if (builder.grid) { for (int i = 0; i < getMenu().size(); i++) { if (getMenu().getItem(i).getIcon() == null) { throw new IllegalArgumentException("You must set icon for each items in grid style"); } } } if (builder.limit > 0) { limit = builder.limit * getNumColumns(); } else { limit = Integer.MAX_VALUE; } mDialogView.setCollapsible(false); actions = builder.menu; menuItem = actions; // over the initial numbers if (getMenu().size() > limit) { fullMenuItem = builder.menu; menuItem = builder.menu.clone(limit - 1); ActionMenuItem item = new ActionMenuItem(context, 0, R.id.bs_more, 0, limit - 1, moreText); item.setIcon(more); menuItem.add(item); actions = menuItem; mDialogView.setCollapsible(true); } BaseAdapter baseAdapter = new BaseAdapter() { @Override public int getCount() { return actions.size() - hidden.size(); } @Override public MenuItem getItem(int position) { return actions.getItem(position); } @Override public int getItemViewType(int position) { MenuItem item = getItem(position); String json = item.getTitle().toString(); int type = parseItemType(json) == null ? -1 : parseItemType(json); switch (type) { case ONE: return ONE; case TWO: return TWO; case NORMAL: return NORMAL; default: return NORMAL; } } @Override public long getItemId(int position) { return position; } @Override public int getViewTypeCount() { return 3; } @Override public boolean isEnabled(int position) { return getItem(position).isEnabled(); } @Override public boolean areAllItemsEnabled() { return false; } @Override public View getView(int position, View convertView, ViewGroup parent) { int type = getItemViewType(position); if (type == ONE) { OneItemViewHolder holder; if (convertView == null) { convertView = View.inflate(context, builder.grid ? mGridItemLayoutId : R.layout.bs_list_entry_hor_one, null); holder = new OneItemViewHolder(convertView); convertView.setTag(holder); } else { holder = (OneItemViewHolder) convertView.getTag(); } for (int i = 0; i < hidden.size(); i++) { if (hidden.valueAt(i) <= position) { position++; } } holder.bindData2View(position); } else if (type == TWO) { TwoItemViewHolder holder; if (convertView == null) { convertView = View.inflate(context, builder.grid ? mGridItemLayoutId : R.layout.bs_list_entry_hor_two, null); holder = new TwoItemViewHolder(convertView); convertView.setTag(holder); } else { holder = (TwoItemViewHolder) convertView.getTag(); } for (int i = 0; i < hidden.size(); i++) { if (hidden.valueAt(i) <= position) { position++; } } holder.bindData2View(position); } else if (type == NORMAL) { NormalItemViewHolder holder; if (convertView == null) { convertView = View.inflate(context, builder.grid ? mGridItemLayoutId : R.layout.bs_list_entry_normal, null); holder = new NormalItemViewHolder(convertView); convertView.setTag(holder); } else { holder = (NormalItemViewHolder) convertView.getTag(); } for (int i = 0; i < hidden.size(); i++) { if (hidden.valueAt(i) <= position) { position++; } } holder.bindData2View(position); } return convertView; } @Nullable private String parseItemTitle(String json) { try { JSONObject jsonObject = new JSONObject(json); String jsonTitle = jsonObject.getString("title"); return jsonTitle; } catch (JSONException e) { e.printStackTrace(); return null; } } private String parseItemContent(String json) { try { JSONObject jsonObject = new JSONObject(json); String content = jsonObject.getString("mContent"); return content; } catch (JSONException e) { e.printStackTrace(); return ""; } } @Nullable private Integer parseItemType(String json) { try { JSONObject jsonObject = new JSONObject(json); Integer type = jsonObject.getInt("type"); return type; } catch (JSONException e) { e.printStackTrace(); return null; } } class TwoItemViewHolder { private TextView divider; private TextView title; private TextView mContent; private ImageView image; public TwoItemViewHolder(View convertView) { title = (TextView) convertView.findViewById(R.id.bs_list_title); image = (ImageView) convertView.findViewById(R.id.bs_list_image); mContent = (TextView) convertView.findViewById(R.id.bs_list_content); divider = (TextView) convertView.findViewById(R.id.bs_list_divider); } private void bindData2View(int position) { MenuItem item = getItem(position); String json = item.getTitle().toString(); // title.setText(json); if (item.getIcon() == null) { image.setVisibility(collapseListIcons ? View.GONE : View.INVISIBLE); } else { image.setVisibility(View.VISIBLE); image.setImageDrawable(item.getIcon()); } boolean showDivider = getCount() > 1 && position != getCount() - 1; divider.setVisibility(showDivider ? View.VISIBLE : View.GONE); String itemTitle = parseItemTitle(json); String contentText = parseItemContent(json); title.setText(parseItemTitle(json)); if (contentText != null && !contentText.trim().isEmpty()) { mContent.setText(contentText); mContent.setVisibility(View.VISIBLE); mContent.setEnabled(true); } else { mContent.setVisibility(View.INVISIBLE); } image.setEnabled(item.isEnabled()); title.setEnabled(item.isEnabled()); } } class NormalItemViewHolder { private TextView title; private ImageView image; public NormalItemViewHolder(View convertView) { title = (TextView) convertView.findViewById(R.id.bs_list_title); image = (ImageView) convertView.findViewById(R.id.bs_list_image); } private void bindData2View(int position) { MenuItem item = getItem(position); String json = item.getTitle().toString(); String titleText = parseItemTitle(json) == null ? json : parseItemTitle(json); title.setText(titleText); if (item.getIcon() == null) { image.setVisibility(collapseListIcons ? View.GONE : View.INVISIBLE); } else { image.setVisibility(View.VISIBLE); image.setImageDrawable(item.getIcon()); } image.setEnabled(item.isEnabled()); title.setEnabled(item.isEnabled()); } } // class MenuItemViewHolder { // // private TextView title; // private ImageView image; // // public MenuItemViewHolder(View convertView) { // title = (TextView) convertView.findViewById(R.id.bs_list_title); // image = (ImageView) convertView.findViewById(R.id.bs_list_image); // } // // private void bindData2View(int position) { // MenuItem item = getItem(position); // String titleText = item.getTitle().toString(); //// String titleText = parseItemTitle(json); // // title.setText(titleText); // if (item.getIcon() == null) { // image.setVisibility(collapseListIcons ? View.GONE : View.INVISIBLE); // } else { // image.setVisibility(View.VISIBLE); // image.setImageDrawable(item.getIcon()); // } // // image.setEnabled(item.isEnabled()); // title.setEnabled(item.isEnabled()); // } // } class OneItemViewHolder { private TextView divider; private TextView title; private ImageView image; public OneItemViewHolder(View convertView) { title = (TextView) convertView.findViewById(R.id.bs_list_title); image = (ImageView) convertView.findViewById(R.id.bs_list_image); divider = (TextView) convertView.findViewById(R.id.bs_list_divider); } private void bindData2View(int position) { MenuItem item = getItem(position); String json = item.getTitle().toString(); title.setText(json); if (item.getIcon() == null) { image.setVisibility(collapseListIcons ? View.GONE : View.INVISIBLE); } else { image.setVisibility(View.VISIBLE); image.setImageDrawable(item.getIcon()); } boolean showDivider = getCount() > 1 && position != getCount() - 1; divider.setVisibility(showDivider ? View.VISIBLE : View.GONE); String itemTitle = parseItemTitle(json); String content = parseItemContent(json); title.setText(parseItemTitle(json)); image.setEnabled(item.isEnabled()); title.setEnabled(item.isEnabled()); } } }; adapter = new SimpleSectionedGridAdapter(context, baseAdapter, R.layout.bs_list_divider, R.id.headerlayout, R.id.header); list.setAdapter(adapter); adapter.setGridView(list); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (((MenuItem) adapter.getItem(position)).getItemId() == R.id.bs_more) { showFullItems(); mDialogView.setCollapsible(false); return; } if (!((ActionMenuItem) adapter.getItem(position)).invoke()) { if (builder.menu.getClickListener() != null) { builder.menu.getClickListener().get(position).onClick(view); } else { if (builder.menulistener != null) { builder.menulistener.onMenuItemClick((MenuItem) adapter.getItem(position)); } else if (builder.listener != null) { builder.listener.onClick(BottomSheet.this, ((MenuItem) adapter.getItem(position)).getItemId()); } } } dismiss(); } }); if (builder.dismissListener != null) { setOnDismissListener(builder.dismissListener); } setListLayout(); }
From source file:com.layer.atlas.AtlasMessagesList.java
public void init(final LayerClient layerClient, final Atlas.ParticipantProvider participantProvider) { if (layerClient == null) throw new IllegalArgumentException("LayerClient cannot be null"); if (participantProvider == null) throw new IllegalArgumentException("ParticipantProvider cannot be null"); this.client = layerClient; LayoutInflater.from(getContext()).inflate(R.layout.atlas_messages_list, this); // --- message view messagesList = (ListView) findViewById(R.id.atlas_messages_list); messagesList.setAdapter(messagesAdapter = new BaseAdapter() { public View getView(int position, View convertView, ViewGroup parent) { final Cell cell = cells.get(position); MessagePart part = cell.messagePart; String userId = part.getMessage().getSender().getUserId(); boolean myMessage = client.getAuthenticatedUserId().equals(userId); if (convertView == null) { convertView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.atlas_view_messages_convert, parent, false); }// w w w . ja v a 2 s . c om View spacerTop = convertView.findViewById(R.id.atlas_view_messages_convert_spacer_top); spacerTop.setVisibility( cell.clusterItemId == cell.clusterHeadItemId && !cell.timeHeader ? View.VISIBLE : View.GONE); View spacerBottom = convertView.findViewById(R.id.atlas_view_messages_convert_spacer_bottom); spacerBottom.setVisibility(cell.clusterTail ? View.VISIBLE : View.GONE); // format date View timeBar = convertView.findViewById(R.id.atlas_view_messages_convert_timebar); TextView timeBarDay = (TextView) convertView .findViewById(R.id.atlas_view_messages_convert_timebar_day); TextView timeBarTime = (TextView) convertView .findViewById(R.id.atlas_view_messages_convert_timebar_time); if (cell.timeHeader) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); long todayMidnight = cal.getTimeInMillis(); long yesterMidnight = todayMidnight - (24 * 60 * 60 * 1000); // 24h less Date sentAt = cell.messagePart.getMessage().getSentAt(); if (sentAt == null) sentAt = new Date(); String timeBarTimeText = timeFormat.format(sentAt.getTime()); String timeBarDayText = null; if (sentAt.getTime() > todayMidnight) { timeBarDayText = "Today"; } else if (sentAt.getTime() > yesterMidnight) { timeBarDayText = "Yesterday"; } else { timeBarDayText = Tools.sdfDayOfWeek.format(sentAt); } timeBarDay.setText(timeBarDayText); timeBarTime.setText(timeBarTimeText); timeBar.setVisibility(View.VISIBLE); } else { timeBar.setVisibility(View.GONE); } TextView textAvatar = (TextView) convertView .findViewById(R.id.atlas_view_messages_convert_initials); View spacerRight = convertView.findViewById(R.id.atlas_view_messages_convert_spacer_right); if (myMessage) { spacerRight.setVisibility(View.GONE); textAvatar.setVisibility(View.INVISIBLE); } else { spacerRight.setVisibility(View.VISIBLE); Atlas.Participant participant = participantProvider.getParticipant(userId); String displayText = participant != null ? Atlas.getInitials(participant) : ""; textAvatar.setText(displayText); textAvatar.setVisibility(View.VISIBLE); } // mark unsent messages View cellContainer = convertView.findViewById(R.id.atlas_view_messages_cell_container); cellContainer.setAlpha( (myMessage && !cell.messagePart.getMessage().isSent()) ? CELL_CONTAINER_ALPHA_UNSENT : CELL_CONTAINER_ALPHA_SENT); // delivery receipt check TextView receiptView = (TextView) convertView .findViewById(R.id.atlas_view_messages_convert_delivery_receipt); receiptView.setVisibility(View.GONE); if (latestDeliveredMessage != null && latestDeliveredMessage.getId().equals(cell.messagePart.getMessage().getId())) { receiptView.setVisibility(View.VISIBLE); receiptView.setText("Delivered"); } if (latestReadMessage != null && latestReadMessage.getId().equals(cell.messagePart.getMessage().getId())) { receiptView.setVisibility(View.VISIBLE); receiptView.setText("Read"); } // processing cell bindCell(convertView, cell); // mark displayed message as read Message msg = part.getMessage(); if (!msg.getSender().getUserId().equals(client.getAuthenticatedUserId())) { msg.markAsRead(); } timeBarDay.setTextColor(dateTextColor); timeBarTime.setTextColor(dateTextColor); textAvatar.setTextColor(avatarTextColor); ((GradientDrawable) textAvatar.getBackground()).setColor(avatarBackgroundColor); return convertView; } private void bindCell(View convertView, final Cell cell) { ViewGroup cellContainer = (ViewGroup) convertView .findViewById(R.id.atlas_view_messages_cell_container); View cellRootView = cell.onBind(cellContainer); boolean alreadyInContainer = false; // cleanUp container cellRootView.setVisibility(View.VISIBLE); for (int iChild = 0; iChild < cellContainer.getChildCount(); iChild++) { View child = cellContainer.getChildAt(iChild); if (child != cellRootView) { child.setVisibility(View.GONE); } else { alreadyInContainer = true; } } if (!alreadyInContainer) { cellContainer.addView(cellRootView); } } public long getItemId(int position) { return position; } public Object getItem(int position) { return cells.get(position); } public int getCount() { return cells.size(); } }); messagesList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Cell item = cells.get(position); if (clickListener != null) { clickListener.onItemClick(item); } } }); // --- end of messageView updateValues(); }
From source file:reportsas.com.formulapp.Formulario.java
public LinearLayout obtenerLayout(LayoutInflater infla, Pregunta preg) { int id;/* w ww . j ava 2 s . co m*/ int tipo_pregunta = preg.getTipoPregunta(); LinearLayout pregunta; TextView textView; TextView textAyuda; switch (tipo_pregunta) { case 1: id = R.layout.pregunta_texto; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloPregunta); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 2: id = R.layout.pregunta_multitexto; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.mtxtTritulo); textAyuda = (TextView) pregunta.findViewById(R.id.mtxtAyuda); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 3: id = R.layout.pregunta_seleccion; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloSeleccion); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_seleccion); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); RadioGroup rg = (RadioGroup) pregunta.findViewById(R.id.opcionesUnica); ArrayList<OpcionForm> opciones = preg.getOpciones(); final ArrayList<RadioButton> rb = new ArrayList<RadioButton>(); for (int i = 0; i < opciones.size(); i++) { OpcionForm opcion = opciones.get(i); rb.add(new RadioButton(this)); rg.addView(rb.get(i)); rb.get(i).setText(opcion.getEtInicial()); } final TextView respt = (TextView) pregunta.findViewById(R.id.respuestaGruop); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int radioButtonID = group.getCheckedRadioButtonId(); RadioButton radioButton = (RadioButton) group.findViewById(radioButtonID); respt.setText(radioButton.getText()); } }); break; case 4: id = R.layout.pregunta_multiple; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloMultiple); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); ArrayList<OpcionForm> opciones2 = preg.getOpciones(); final EditText ediOtros = new EditText(this); ArrayList<CheckBox> cb = new ArrayList<CheckBox>(); for (int i = 0; i < opciones2.size(); i++) { OpcionForm opcion = opciones2.get(i); cb.add(new CheckBox(this)); pregunta.addView(cb.get(i)); cb.get(i).setText(opcion.getEtInicial()); if (opcion.getEditble().equals("S")) { ediOtros.setEnabled(false); ediOtros.setId(R.id.edtTexto); pregunta.addView(ediOtros); cb.get(i).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { ediOtros.setEnabled(true); } else { ediOtros.setText(""); ediOtros.setEnabled(false); } } }); } } TextView spacio = new TextView(this); spacio.setText(" "); spacio.setVisibility(View.INVISIBLE); pregunta.addView(spacio); break; case 5: id = R.layout.pregunta_escala; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloEscala); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_escala); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); TextView etInicial = (TextView) pregunta.findViewById(R.id.etInicial); TextView etFinal = (TextView) pregunta.findViewById(R.id.etFinal); OpcionForm opci = preg.getOpciones().get(0); etInicial.setText(opci.getEtInicial()); etFinal.setText(opci.getEtFinal()); final TextView respEscala = (TextView) pregunta.findViewById(R.id.seleEscala); RatingBar rtBar = (RatingBar) pregunta.findViewById(R.id.escala); rtBar.setNumStars(Integer.parseInt(opci.getValores().get(0).getDescripcion())); rtBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { respEscala.setText("" + Math.round(rating)); } }); break; case 6: id = R.layout.pregunta_lista; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloLista); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_lista); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); ArrayList<OpcionForm> opciones3 = preg.getOpciones(); //Creamos la lista LinkedList<ObjetoSpinner> opcn = new LinkedList<ObjetoSpinner>(); //La poblamos con los ejemplos for (int i = 0; i < opciones3.size(); i++) { opcn.add(new ObjetoSpinner(opciones3.get(i).getIdOpcion(), opciones3.get(i).getEtInicial())); } //Creamos el adaptador*/ Spinner listad = (Spinner) pregunta.findViewById(R.id.opcionesListado); ArrayAdapter<ObjetoSpinner> spinner_adapter = new ArrayAdapter<ObjetoSpinner>(this, android.R.layout.simple_spinner_item, opcn); //Aadimos el layout para el men y se lo damos al spinner spinner_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); listad.setAdapter(spinner_adapter); break; case 7: id = R.layout.pregunta_tabla; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloTabla); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_tabla); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); TableLayout tba = (TableLayout) pregunta.findViewById(R.id.tablaOpciones); ArrayList<OpcionForm> opciones4 = preg.getOpciones(); ArrayList<RadioButton> radiosbotonoes = new ArrayList<RadioButton>(); for (int i = 0; i < opciones4.size(); i++) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.row_pregunta_tabla, null); RadioGroup tg_valores = (RadioGroup) row.findViewById(R.id.valoresRow); final ArrayList<RadioButton> valoOpc = new ArrayList<RadioButton>(); ArrayList<Valor> valoresT = opciones4.get(i).getValores(); for (int k = 0; k < valoresT.size(); k++) { RadioButton rb_nuevo = new RadioButton(this); rb_nuevo.setText(valoresT.get(k).getDescripcion()); tg_valores.addView(rb_nuevo); valoOpc.add(rb_nuevo); } ((TextView) row.findViewById(R.id.textoRow)).setText(opciones4.get(i).getEtInicial()); tba.addView(row); } TextView espacio = new TextView(this); espacio.setText(" "); pregunta.addView(espacio); break; case 8: id = R.layout.pregunta_fecha; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloFecha); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_fecha); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 9: id = R.layout.pregunta_hora; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloHora); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_hora); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; default: id = R.layout.pregunta_multiple; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloMultiple); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; } return pregunta; }
From source file:com.example.SmartBoard.DrawingView.java
public Bitmap textToBitmap(String text, int color, float posX, float posY, int size) { TextView textView = new TextView(getContext()); textView.setVisibility(View.VISIBLE); textView.setTextColor(color);/* w ww . j a v a 2s. co m*/ textView.setMaxWidth(500); textView.setMaxHeight(500); textView.setMaxLines(4); textView.setX(posX); textView.setY(posY); textView.setText(text); textView.setTextSize(size); LinearLayout layout = new LinearLayout(getContext()); layout.addView(textView); layout.measure(500, 500); layout.layout(0, 0, 500, 500); textView.setDrawingCacheEnabled(true); textView.buildDrawingCache(); Bitmap bm = textView.getDrawingCache(); return bm; }
From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java
public void showTrialDialog(final boolean expired, int numDaysRemaining) { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle(R.string.app_name); builder.setCancelable(false);//from w ww. j a v a 2 s .c o m View view = this.getLayoutInflater().inflate(R.layout.trial_expiry_dialog, null); TextView trialExpiredText = (TextView) view.findViewById(R.id.trial_message); TextView trialDaysRemaining = (TextView) view.findViewById(R.id.trial_days_remaining); TextView trialDaysCaps = (TextView) view.findViewById(R.id.days_caps); trialExpiredText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); trialExpiredText .setPaintFlags(trialExpiredText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); trialDaysRemaining.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); trialDaysCaps.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); trialDaysCaps .setPaintFlags(trialDaysCaps.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); if (expired) { trialDaysRemaining.setText(R.string.expired); trialExpiredText.setText(R.string.trial_expired); trialDaysRemaining.setTextColor(0xFFFF8800); trialDaysCaps.setVisibility(View.GONE); trialDaysRemaining.setTextSize(36); trialDaysRemaining.setPaintFlags( trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); } else { trialExpiredText.setText(R.string.trial_running); trialDaysRemaining.setText("" + numDaysRemaining); trialDaysCaps.setVisibility(View.VISIBLE); trialDaysRemaining.setTextColor(0xFF0099CC); trialDaysRemaining.setPaintFlags(trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG); } builder.setView(view); builder.setPositiveButton(R.string.upgrade, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showUpgradeFragmentWithPromo(); } }); builder.setNegativeButton(R.string.later, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (expired) { finish(); } else { launchMainActivity(); } } }); builder.create().show(); }
From source file:com.github.rutvijkumar.twittfuse.TwitterUtil.java
public void markFavorite(final Tweet tweet, final ImageButton favAction, final TextView countView, final boolean hideZero) { if (!Util.isNetworkAvailable(activity)) { Util.showNetworkUnavailable(activity); }/* w w w .j a va 2 s . c o m*/ client.markTweetFavorite(tweet.isFavorited(), String.valueOf(tweet.getUid()), new JsonHttpResponseHandler() { // @Override // public void onSuccess(int statusCode, Header[] headers, // JSONObject response) { // onSuccess(response); // } // @Override // public void onFailure(int statusCode, Header[] headers, // Throwable throwable, JSONObject errorResponse) { // onFailure(throwable, errorResponse); // } @Override public void onSuccess(JSONObject body) { boolean isFav = tweet.isFavorited(); long newFavCount = tweet.getFavouritesCount(); if (isFav) { newFavCount++; } else { newFavCount--; } if (hideZero) { if (newFavCount == 0) { countView.setVisibility(View.INVISIBLE); } else { countView.setVisibility(View.VISIBLE); } } tweet.setFavouritesCount(newFavCount); tweet.save(); countView.setText(String.valueOf(newFavCount)); setFavView(tweet.isFavorited(), favAction); } public void onFailure(Throwable e, JSONObject error) { Log.d("DEBUG", error.toString()); Log.e("ERROR", "Exception while marking fav", e); } }); }
From source file:com.example.zayankovsky.homework.ui.ImageDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image_detail); getWindow().getDecorView().setBackgroundResource( PreferenceManager.getDefaultSharedPreferences(this).getString("theme", "light").equals("dark") ? R.color.darkColorTransparent : R.color.lightColorTransparent); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Locate the main ImageView and TextView mImageView = (ImageView) findViewById(R.id.imageView); final TextView mTextView = (TextView) findViewById(R.id.textView); mSectionNumber = getIntent().getIntExtra(SECTION_NUMBER, 0); registerForContextMenu(mImageView);/*from w ww . ja v a 2s . c o m*/ mImageView.setLongClickable(false); // Enable some additional newer visibility and ActionBar features // to create a more immersive photo viewing experience final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Set home as up actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar and TextView as the visibility changes mImageView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); if (mSectionNumber == 1) { mTextView.animate().translationY(mTextView.getHeight()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mTextView.setVisibility(View.GONE); } }); } } else { actionBar.show(); if (mSectionNumber == 1) { mTextView.animate().translationY(0).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mTextView.setVisibility(View.VISIBLE); } }); } } } }); // Start low profile mode and hide ActionBar mImageView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } GestureListener.init(this, mImageView); ScaleGestureListener.init(mImageView); // Use the ImageWorker to load the image into the ImageView // (so a single cache can be used over all pages in the ViewPager) // based on the extra passed in to this activity int position = getIntent().getIntExtra(POSITION, 0); switch (mSectionNumber) { case 0: GalleryWorker.loadImage(position, mImageView); break; case 1: FotkiWorker.loadImage(position, mImageView); mTextView.setText(getResources().getString(R.string.detail_text, FotkiWorker.getAuthor(), new SimpleDateFormat("d MMMM yyyy", Locale.getDefault()).format(FotkiWorker.getPublished()))); break; case 2: ResourcesWorker.loadImage(position, mImageView); break; } setTitle(ImageWorker.getTitle()); // First we create the GestureListener that will include all our callbacks. // Then we create the GestureDetector, which takes that listener as an argument. GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener(); final GestureDetector gd = new GestureDetector(this, gestureListener); ScaleGestureDetector.SimpleOnScaleGestureListener scaleGestureListener = new ScaleGestureListener(); final ScaleGestureDetector sgd = new ScaleGestureDetector(this, scaleGestureListener); /* For the view where gestures will occur, we create an onTouchListener that sends * all motion events to the gesture detectors. When the gesture detectors * actually detects an event, it will use the callbacks we created in the * SimpleOnGestureListener and SimpleOnScaleGestureListener to alert our application. */ findViewById(R.id.frameLayout).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { gd.onTouchEvent(motionEvent); sgd.onTouchEvent(motionEvent); return true; } }); }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
/** * display advertising report filter views * * @param view//from ww w. j a va2 s .c o m */ private void displayAdvertizingReportFilter(View view) { displaySubEventSpinner(view); TextView device_address_label = (TextView) view.findViewById(R.id.device_address_label); device_address_label.setVisibility(View.VISIBLE); EditText device_address_edit = (EditText) view.findViewById(R.id.device_address_edit); device_address_edit.setVisibility(View.VISIBLE); }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
/** * setup visibility of all filter spinner * * @param view//from w w w. j a va 2 s . c o m */ private void displayCmdSpinner(View view) { Spinner ogf_filter = (Spinner) view.findViewById(R.id.cmd_ogf_filter); ogf_filter.setVisibility(View.VISIBLE); Spinner event_type_filter = (Spinner) view.findViewById(R.id.event_type_filter); event_type_filter.setVisibility(View.GONE); Spinner subevent_type_filter = (Spinner) view.findViewById(R.id.subevent_type_filter); subevent_type_filter.setVisibility(View.GONE); TextView device_address_label = (TextView) view.findViewById(R.id.device_address_label); device_address_label.setVisibility(View.GONE); EditText device_address_edit = (EditText) view.findViewById(R.id.device_address_edit); device_address_edit.setVisibility(View.GONE); }
From source file:com.borax12.materialdaterangepicker.time.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.range_time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description); mSelectHours = res.getString(R.string.mdtp_select_hours); mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description); mSelectMinutes = res.getString(R.string.mdtp_select_minutes); mSelectedColor = res.getColor(R.color.mdtp_white); mUnselectedColor = res.getColor(R.color.mdtp_accent_color_focused); tabHost = (TabHost) view.findViewById(R.id.tabHost); tabHost.findViewById(R.id.tabHost);/*w w w.j a v a 2 s.com*/ tabHost.setup(); TabHost.TabSpec startDatePage = tabHost.newTabSpec("start"); startDatePage.setContent(R.id.start_date_group); startDatePage.setIndicator("FROM"); TabHost.TabSpec endDatePage = tabHost.newTabSpec("end"); endDatePage.setContent(R.id.end_date_group); endDatePage.setIndicator("TO"); tabHost.addTab(startDatePage); tabHost.addTab(endDatePage); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourViewEnd = (TextView) view.findViewById(R.id.hours_end); mHourViewEnd.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mHourSpaceViewEnd = (TextView) view.findViewById(R.id.hour_space_end); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteSpaceViewEnd = (TextView) view.findViewById(R.id.minutes_space_end); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mMinuteViewEnd = (TextView) view.findViewById(R.id.minutes_end); mMinuteViewEnd.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); mAmPmTextViewEnd = (TextView) view.findViewById(R.id.ampm_label_end); mAmPmTextViewEnd.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getActivity()); mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), this, mInitialHourOfDay, mInitialMinute, mIs24HourMode); mTimePickerEnd = (RadialPickerLayout) view.findViewById(R.id.time_picker_end); mTimePickerEnd.setOnValueSelectedListener(this); mTimePickerEnd.setOnKeyListener(keyboardListener); mTimePickerEnd.initialize(getActivity(), this, mInitialHourOfDay, mInitialMinute, mIs24HourMode); int currentItemShowing = HOUR_INDEX; int currentItemShowingEnd = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING_END)) { currentItemShowingEnd = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING_END); } setCurrentItemShowing(currentItemShowing, false, true, true); setCurrentItemShowing(currentItemShowingEnd, false, true, true); mTimePicker.invalidate(); mTimePickerEnd.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } }); mHourViewEnd.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } }); mMinuteViewEnd.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } }); mOkButton = (Button) view.findViewById(R.id.ok); mOkButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes(), mTimePickerEnd.getHours(), mTimePickerEnd.getMinutes()); } dismiss(); } }); mOkButton.setOnKeyListener(keyboardListener); mOkButton.setTypeface(TypefaceHelper.get(getDialog().getContext(), "Roboto-Medium")); mCancelButton = (Button) view.findViewById(R.id.cancel); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); mCancelButton.setTypeface(TypefaceHelper.get(getDialog().getContext(), "Roboto-Medium")); mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); mAmPmHitspaceEnd = view.findViewById(R.id.ampm_hitspace_end); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); mAmPmTextViewEnd.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); TextView separatorViewEnd = (TextView) view.findViewById(R.id.separator_end); separatorView.setLayoutParams(paramsSeparator); separatorViewEnd.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); mAmPmTextViewEnd.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); mAmPmHitspaceEnd.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePickerEnd.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePickerEnd.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder); mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); mHourViewEnd.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<>(); } // Set the title (if any) TextView timePickerHeader = (TextView) view.findViewById(R.id.time_picker_header); TextView timePickerHeaderEnd = (TextView) view.findViewById(R.id.time_picker_header_end); if (!mTitle.isEmpty()) { timePickerHeader.setVisibility(TextView.VISIBLE); timePickerHeader.setText(mTitle); timePickerHeaderEnd.setVisibility(TextView.VISIBLE); timePickerHeaderEnd.setText(mTitle); } // Set the theme at the end so that the initialize()s above don't counteract the theme. mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark); mTimePickerEnd.setTheme(getActivity().getApplicationContext(), mThemeDark); //If an accent color has not been set manually, try and get it from the context if (mAccentColor == -1) { int accentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); if (accentColor != -1) { mAccentColor = accentColor; } } if (mAccentColor != -1) { mTimePicker.setAccentColor(mAccentColor); mTimePickerEnd.setAccentColor(mAccentColor); mOkButton.setTextColor(mAccentColor); } else { int circleBackground = res.getColor(R.color.mdtp_circle_background); int backgroundColor = res.getColor(R.color.mdtp_background_color); int darkBackgroundColor = res.getColor(R.color.mdtp_light_gray); int lightGray = res.getColor(R.color.mdtp_light_gray); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); mTimePickerEnd.setBackgroundColor(mThemeDark ? lightGray : circleBackground); view.findViewById(R.id.time_picker_dialog) .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor); } tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if (tabId == "start") { setCurrentItemShowing(mTimePicker.getCurrentItemShowing(), true, false, true); setHour(mTimePicker.getHours(), false); setMinute(mTimePicker.getMinutes()); updateAmPmDisplay(mTimePicker.getIsCurrentlyAmOrPm()); } else { setCurrentItemShowing(mTimePickerEnd.getCurrentItemShowing(), true, false, true); setHour(mTimePickerEnd.getHours(), false); setMinute(mTimePickerEnd.getMinutes()); updateAmPmDisplay(mTimePickerEnd.getIsCurrentlyAmOrPm()); } } }); return view; }