imageview

ImageView without xml definition

£可爱£侵袭症+ 提交于 2019-11-28 12:32:04
I want to create a dynamic number of ImageViews in Android. But to display these ImageViews I have to create them in the main.xml (Am I right?) Is there a way to display the ImageViews without creating them in the main.xml? Akram You can create them dynamically like this: ImageView image=new ImageView(this); and to set image in this dynamically created view use: image.setImageResource(R.drawable.yourimage); Put your image my_image.jpg into res/drawable/my_image.jpg and use: import android.app.Activity; import android.os.Bundle; import android.widget.ImageView; public class Main extends

Picasso java.lang.IllegalStateException: Method call should not happen from the main thread

左心房为你撑大大i 提交于 2019-11-28 11:57:51
I am attempting to use Picasso to get three Bitmap images from a URL public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab2); Drawable d1 = new BitmapDrawable(Picasso.with(Tab2.this).load(zestimateImg1).get()); } I am getting FATAL EXCEPTION with this code. I suspect it has to do with the fact that this should be done within AsyncTask , but I can't get it to work. If using that is avoidable, I would like to do this without using AsyncTask . How can I get this code to run without crashing? If the best way to do this is with AsyncTask ,

Glide listener doesn't work

半城伤御伤魂 提交于 2019-11-28 11:52:34
I'm using Glide to load images and I added a listener to know when resource is ready or if there was an error of any type: Glide.with(mContext) .load(url) .placeholder(R.drawable.glide_placeholder) // use dontAnimate and not crossFade to avoid a bug with custom views .dontAnimate() .diskCacheStrategy(DiskCacheStrategy.ALL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { // do something return true; } @Override public boolean onResourceReady(GlideDrawable resource,

RecyclerView with only one item displayed on screen [duplicate]

落花浮王杯 提交于 2019-11-28 11:38:08
This question already has an answer here: RecyclerView horizontal scroll snap in center 7 answers I have RecyclerView with items ImageView . I want to make RecyclerView to display only one item at time, dragging to edge like ViewPager , when changing. Anyone knows how to achieve this? I'm using code from this source: Android Simple RecyclerView Widget Example Only one difference is that I don't have TextView , only ImageView . As from I see you need a vertical ViewPager. I'm using castorflex/VerticalViewPager library for achieving that for one of my projects. It works just like a ViewPager, no

How to store and retrieve bitmap in sharedPreferences in Android?

心已入冬 提交于 2019-11-28 11:10:20
I am new in Android. I want to store my bitmap in sharedPreferences. Can anyone tell me how it will possible? Actually my requirements is, I fetch the image from gallery as well as take picture from camera and I set that Bitmap in my ImageView. These all things work properly. But when I click on back button all ImageView will be empty. So I want to store that Bitmaps throughout my application. Can anyone help me? I am very much stuck on this. Thanks. Hey friends I got the solution of my problem here I post my code so that others can use this solution.. 1). on button click - open camera for

Inflated ImageView to put in GalleryView isn't the right size

女生的网名这么多〃 提交于 2019-11-28 11:05:56
I am trying to inflate an ImageView that scales a Drawable that I can display in a GalleryView. My code to inflate the view seems to work fine, except that the attributes of the ImageView are not applied. Specifically, the inflated ImageView does not have the width/height that I set for it via the android:layout params in XML. Can someone show me what I'm doing wrong? I want to set the width/height of the image in dp, so that it is the correct size across multiple screen dpis and support Android 1.5+. As a result I cannot use something like: i.setLayoutParams(new Gallery.LayoutParams(150, 116)

android multitouch image zooming?

拈花ヽ惹草 提交于 2019-11-28 10:54:06
I'm displaying an image on full screen now i want to zoom it in or out. Any one guide on how I can implement multi touch image zooming? I am using the 2.1 sdk version. Janusz There is the possibility to use a webview to display a local file. The Webview has integrated multitouch zooming. Have a look at my question regarding this topic. I have a working implementation for 2.1+ WebView solution caused problems for me on 4.0.x (lot's of weird white spaces appearing) https://github.com/jasonpolites/gesture-imageview Might be useful for someone... A recent post on the Android Developers Blog

Android : getting NullPointerException for ImageView imag = (ImageView) findViewById(R.id.image)

北慕城南 提交于 2019-11-28 10:51:01
问题 I am getting Null Pointer Exception for ImageView imag = (ImageView) findViewById(R.id.image). I have custome layout declared in R.layout.screen3 with custome list declared in R.layout.custom_row_screen3 . Each row has few tasks and depending on their status an image is shown to right of each row. Please guide me in getting this resolved as I am new to android. here is my code below ::: public class screen3 extends ListActivity{ final ArrayList<HashMap<String, String>> list = new ArrayList

Changing ImageView on button click

丶灬走出姿态 提交于 2019-11-28 10:36:51
问题 Wondering if I'm going about this the right way or not. I have 3 buttons on my screen (Restart, Previous, Next). When the view loads it shows the first image which is fine. When I click the "Next" button I want it to load a second image and so on for up to 9 images. If I click the "Previous" button it should go back one image. Clicking "Restart" should go to the first image. I have the Restart one working. I'm having trouble with the Next button because it only shows the second image (I think

ImageView OutofMemoryException

做~自己de王妃 提交于 2019-11-28 10:36:06
I have a problem when inserting an image in an ImageView. I have tried several ways to solve it but it still fails, the latest version follows. The image size is 3000x3000. Code: ImageView iv = (ImageView) findViewById(R.id.imageView); Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.prueba_plano_2).copy(Bitmap.Config.ARGB_8888, true); iv.setImageBitmap(originalBitmap); XML: <FrameLayout android:id="@+id/root" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true"