0

Does anyone know how to display my application in Gallery, and then when clicked it uploads this into the imageView and and then after that i upload it using an api. But how do i accomplish this? Btw im sorry if this has already been asked i could not find something that was simple to understand, i just started developing android applications.

if more information is needed just ask

  • http://www.androidinterview.com/android-gallery-view-example-displaying-a-list-of-images/ ,,,,,,refer this link –  Mar 22 '16 at 12:13
  • I made what you did but this tells me how to get it from drawable but how do i load my images into that image view ? and how do i get it directly after taking a picture? –  Mar 22 '16 at 12:34

3 Answers3

0

You can Create custom gallery. sample example of custom gallery or refer this solution you have to set selected image on imageview

Community
  • 1
  • 1
Ajay Pandya
  • 2,417
  • 4
  • 29
  • 65
0
public class MainActivity extends AppCompatActivity {
    private ImageButton btn;
    private ImageView imageView;
    private static int RESULT_LOAD_IMAGE = 1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
       btn=(ImageButton)findViewById(R.id.imageButton);
       btn.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
               startActivityForResult(i, RESULT_LOAD_IMAGE);
           }
       });
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
            Uri selectedImage = data.getData();
            String[] filePathColumn = { MediaStore.Images.Media.DATA };

            Cursor cursor = getContentResolver().query(selectedImage,
            filePathColumn, null, null, null);
            cursor.moveToFirst();
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String picturePath = cursor.getString(columnIndex);
            cursor.close();

            imageView = (ImageView) findViewById(R.id.imgView);
        imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));

        }
    }
}

//manage main.xml by yourself

Umesh Pithiya
  • 28
  • 1
  • 6
0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:orientation="vertical">

    <ImageButton
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton"
    android:layout_gravity="center_horizontal" />

   <ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:layout_gravity="center_horizontal" />
</LinearLayout>
Umesh Pithiya
  • 28
  • 1
  • 6