Quiero mostrar la barra de progreso (spinner) a la derecha de editText cuando la actividad está haciendo algún procesamiento y ocultarla al finalizar, ¿hay alguna manera simple de hacerlo?barra de progreso de Android dentro de edittext
Respuesta
que haría uso de RelativeLayout
, algo como esto:
<RelativeLayout>
<EditText
android:id="@+id/the_id"/>
<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_alignTop="@id/the_id"
android:layout_alignBottom="@id/the_id"
android:layout_alignRight="@id/the_id"/>
</RelativeLayout>
probar este ...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:ems="10"
android:hint="@string/app_name"
android:inputType="textNoSuggestions"
android:padding="8dp" >
</EditText>
<ProgressBar
style="?android:attr/progressBarStyleInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/editText"
android:layout_alignRight="@id/editText"
android:layout_alignTop="@id/editText" />
</RelativeLayout>
</LinearLayout>
respuesta tardía, pero, tal vez alguien va a utilizar esto.
Creé una nueva vista que realmente está haciendo el trabajo por mí.
Así, en primer lugar, crear un diseño xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.view.InstantAutoComplete
android:id="@+id/custom_edit_text_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/layout_padding"/>
<ProgressBar
android:id="@+id/custom_edit_text_progress_bar"
style="@style/SmallProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:visibility="gone"/>
</RelativeLayout>
Ahora, una clase Java:
public class CustomEditText extends RelativeLayout {
private LayoutInflater mInflater = null;
private AutocompleteEditText mEditText;
private ProgressBar mProgressBar;
private boolean mIsRefreshing = false;
private int textColor;
private int hintTextColor;
private String hint;
private int textSize;
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
initViews(attrs);
}
public CustomEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initViews(attrs);
}
private void initViews(AttributeSet attrs) {
mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mInflater.inflate(R.layout.custom_layout_edit_text, this, true);
mEditText = (AutocompleteEditText) findViewById(R.id.custom_edit_text_edit_text);
mProgressBar = (ProgressBar) findViewById(R.id.custom_edit_text_progress_bar);
mProgressBar.getLayoutParams().height = mEditText.getLayoutParams().height - 30;
mProgressBar.getLayoutParams().width = mEditText.getLayoutParams().height - 30;
mProgressBar.requestLayout();
TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.CustomEditText, 0, 0);
try {
textColor = a.getInteger(R.styleable.CustomEditText_textColor, R.color.black);
hint = a.getString(R.styleable.CustomEditText_hint);
hintTextColor = a.getInteger(R.styleable.CustomEditText_hintTextColor, R.color.black);
textSize = a.getDimensionPixelSize(R.styleable.CustomEditText_textSize, R.dimen.text_medium_size);
} finally {
a.recycle();
}
mEditText.setTextColor(textColor);
mEditText.setHint(hint);
mEditText.setHintTextColor(hintTextColor);
mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
}
public void setRefreshing(boolean isVisible) {
if (isVisible) {
if (!mIsRefreshing) {
mIsRefreshing = true;
mProgressBar.setVisibility(VISIBLE);
}
} else {
if (mIsRefreshing) {
mIsRefreshing = false;
mProgressBar.setVisibility(GONE);
}
}
}
public AutocompleteEditText getEditText() {
return mEditText;
}
public ProgressBar getProgressBar() {
return mProgressBar;
}
}
definir sus atributos para que pueda utilizarlo en XML. En su carpeta de valores, crear un archivo .xml attrs nombre:
<resources>
<declare-styleable name="CustomEditText">
<attr name="hint" format="string"/>
<attr name="textColor" format="color"/>
<attr name="textSize" format="dimension"/>
<attr name="hintTextColor" format="color"/>
</declare-styleable>
</resources>
Y finalmente utilizarlo en que la actividad/fragmento como:
<com.CustomEditText
android:id="@+id/reply_to_request_main_course_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_padding"
android:layout_weight="1"
app:textColor="@color/black"
app:textSize="@dimen/text_medium_size"/>
Usted instansiate objeto de la actividad/fragmento. Cuando se quiere llamar a la barra de progreso para ser visible, sólo tiene que escribir
mEditText.setRefreshing(true/false);
¿Es posible añadir los valores color.xml y dimen.xml que utilizó? – 4gus71n
- 1. Barra de progreso personalizado Android
- 2. sintaxis de estilo barra de progreso Android
- 3. Barra de progreso de Android en ImageView
- 4. barra de progreso Android con relleno
- 5. Barra de progreso personalizado en Android?
- 6. barra de progreso vertical en Android
- 7. Subir la barra de progreso en Android?
- 8. insertando textview dentro de edittext en android?
- 9. barra de progreso circular
- 10. Barra de progreso vertical
- 11. wxPython barra de progreso
- 12. ¿Cómo hacer una barra de progreso personalizada en Android?
- 13. Activación de la barra de desplazamiento en EditText Android
- 14. Barra de progreso de Python
- 15. Cambiar el color de la barra de progreso en Android
- 16. Cómo mostrar una barra de progreso indeterminado horizontal de Android
- 17. Barra de progreso de Android en el botón
- 18. Actualizar la barra de progreso en la barra de notificaciones
- 19. HTML5 Audio - Barra de progreso
- 20. oscilación con barra de progreso
- 21. Django-apio barra de progreso
- 22. QT barra de progreso velocidad
- 23. Barra de progreso para AVAssetExportSession
- 24. Agregar una barra de progreso en WebView
- 25. Barra de progreso redondeada en ambos lados en Android
- 26. Barra de título personalizado con progreso en Android
- 27. ¿Cómo ocultar la barra de progreso en Android?
- 28. progreso indeterminada en Sherlock Barra de acción
- 29. Patrones de diseño de barra de progreso?
- 30. Mostrar barra de progreso indeterminada en la barra de estado en Android
Gracias eso es exactamente lo que estaba buscando – mkso