Permitir al usuario insertar una imagen en la aplicación android
Mi pregunta es: ¿cómo crear imageButton que permiten al usuario cargar la imagen de su teléfono e insertarlo en la aplicación como un perfil de imagen? Como whatsapp, por ejemplo, permite al usuario elegir la imagen desde el teléfono y configurarlo como un perfil de imagen.
Gracias
- Android: My App Widget con ListView no se actualiza a través del botón o período de actualización
- ¿Puede un widget de casa tener un Contexto?
- Cómo obtener texto seleccionado de edittext en android?
- Android: Actualizar el widget en la disponibilidad de la conexión de red
- ¿Hay algún ejemplo sobre el texto Spanned y Spannable?
- Listview normal y coloque el estilo de fondo en android
- Actualización frecuente de widgets (más frecuentemente de lo que permite updatePeriodMillis)
- ¿Cómo acceder a recurso con nombre dinámico en mi caso?
- Cómo cambiar android spinner popupBackground
- Pasar extras del widget en PendingIntent a Actividad
- Transmitir una matriz de enteros desde un AppWidget a un RemoteViewsService preexistente para ser renderizado por el RemoteViewsFactory
- Cómo calcular el tamaño de widget Android adecuado?
- Android: problemas de setSelection () de la galería personalizada
Aquí están los siguientes enlaces ..
Crear botón de imagen
cargar imagen
Ejemplo 1
Ejemplo 2
Ejemplo 3
MI ARCHIVO XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@android:id/icon" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:onClick="selectImage" />
MI ARCHIVO
public class Test extends AppCompatActivity { private static final int SELECT_PICTURE = 0; private ImageView imageView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); imageView = (ImageView) findViewById(android.R.id.icon); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { Bitmap bitmap = getPath(data.getData()); imageView.setImageBitmap(bitmap); } } private Bitmap getPath(Uri uri) { String[] projection = {MediaStore.Images.Media.DATA}; Cursor cursor = managedQuery(uri, projection, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String filePath = cursor.getString(column_index); // cursor.close(); // Convert file path into bitmap image using below line. Bitmap bitmap = BitmapFactory.decodeFile(filePath); return bitmap; } private void selectImage() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); } }
- ¿Es posible crear una tabla sqlite en tiempo de ejecución basada en el número de elementos en matriz
- Medir el tiempo empleado en las aplicaciones de Android