Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void guardar(View view) {
- Intent i = new Intent( this, MainActivity.class);
- edit = findViewById(R.id.editText);
- String number= edit.getText().toString();
- String imagenUri = String.valueOf(getImageUri());
- i.putExtra("imagen",imagenUri);
- i.putExtra("tara", number);
- startActivity(i);
- }
- peso = extras.getString("tara");
- uri = extras.getString("imagen");
- ArrayList<ImagenesFoto> results = new ArrayList<ImagenesFoto>();
- ImagenesFoto sr1 = new ImagenesFoto();
- sr1.setTaraImagen(peso);
- sr1.setRutaImagen(uri);
- results.add(sr1);
- grid = view.findViewById(R.id.gridView);
- GridViewAdapter gridViewAdapter= new GridViewAdapter(getContext(), results);
- grid.setAdapter(gridViewAdapter);
- public class GridViewAdapter extends BaseAdapter {
- private ArrayList<ImagenesFoto> searchArrayList;
- private LayoutInflater mInflater;
- GridViewAdapter(Context context, ArrayList<ImagenesFoto> results) {
- this.searchArrayList = results;
- mInflater = LayoutInflater.from(context);
- }
- @Override
- public int getCount() {
- return searchArrayList.size();
- }
- @Override
- public Object getItem(int position) {
- return searchArrayList.get(position);
- }
- @Override
- public long getItemId(int position) {
- return position;
- }
- @SuppressLint("InflateParams")
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder holder;
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.grid_item,null);
- holder = new ViewHolder();
- holder.pesoTara = convertView.findViewById(R.id.pesoTara);
- holder.img = convertView.findViewById(R.id.img);
- convertView.setTag(holder);
- } else {
- holder = (ViewHolder) convertView.getTag();
- }
- holder.img.setImageURI(Uri.parse(searchArrayList.get(position).getRutaImagen()));
- holder.pesoTara.setText(searchArrayList.get(position).getTaraImagen());
- return convertView;
- }
- static class ViewHolder {
- TextView pesoTara;
- ImageView img;
- }
- public class ImagenesFoto {
- public String rutaImagen;
- public String taraImagen;
- public String getRutaImagen() {
- return rutaImagen;
- }
- public void setRutaImagen(String rutaImagen) {
- this.rutaImagen = rutaImagen;
- }
- public String getTaraImagen() {
- return taraImagen;
- }
- public void setTaraImagen(String taraImagen) {
- this.taraImagen = taraImagen;
- }
- <LinearLayout
- android:id="@+id/tab1"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <ListView
- android:id="@+id/gridView"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- </ListView>
- <android.support.v7.widget.CardView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="5dp"
- android:id="@+id/cardView">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:weightSum="10">
- <ImageView
- android:layout_weight="2"
- android:id="@+id/img"
- android:layout_width="match_parent"
- android:layout_height="120dp" />
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="8"
- android:orientation="horizontal">
- <TextView
- android:layout_weight="1"
- android:id="@+id/textTara"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:text="Tara"
- android:textAlignment="center"
- android:textColor="#000" />
- <TextView
- android:layout_weight="1"
- android:id="@+id/pesoTara"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:hint="Tara"
- android:textAlignment="center"/>
- </LinearLayout>
- </LinearLayout>
Add Comment
Please, Sign In to add comment