imageview

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

ⅰ亾dé卋堺 提交于 2019-11-29 17:04:20
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<HashMap<String, String>>(); ... ... ... TextView tv; ImageView imag; @Override public void onCreate

Changing ImageView on button click

十年热恋 提交于 2019-11-29 16:47:01
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 because my "a" variable is initialized at 0). Here's my code. Grateful to anyone that can help. public

Unexplained gap/padding to the left, between Toolbar, and LinearLayout

有些话、适合烂在心里 提交于 2019-11-29 16:46:34
问题 I have the following structure in the layout file of my Android studio project, and I see unexplained left padding between the parent element (Toolbar) and it's immediate child element (LinearLayout). Layout Text <Toolbar android:layout_width="fill_parent" android:layout_height="600dp" android:id="@+id/toolbar" android:background="#313B45" android:weightSum="1"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView

catch “RuntimeException: Canvas: trying to draw too large…”

混江龙づ霸主 提交于 2019-11-29 15:49:07
I have an application which draws an image from the file system to screen like so: Bitmap image = BitmapFactory.decodeFile(file.getPath()); imageView.setImageBitmap(image); If the image is very large I see this error: java.lang.RuntimeException: Canvas: trying to draw too large(213828900bytes) bitmap. at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260) at android.graphics.Canvas.drawBitmap(Canvas.java:1415) ... The stack does not reach my code. How can I catch this error? Or is there a more appropriate way to be drawing the image to the imageView that can avoid this

Loading an image in ImageView through code

被刻印的时光 ゝ 提交于 2019-11-29 15:34:55
I have built my application using scenebuilder for javafx. I have a form where a person has to upload an image. I used this code public void photoChooser(ActionEvent evt) { System.out.println("photoChooser method is called"); try{ FileChooser fileChooser= new FileChooser(); fileChooser.setTitle("Choose a file"); File file = fileChooser.showOpenDialog(stagehere); if(file != null){ System.out.println(file); String img = file.toString(); //Image image = new ImageIcon(img); try{ // image= new Image(); Image image = new Image(img); } catch (Exception e) {System.out.println("Can't upload image " + e

How to display an image full size with ImageView?

大兔子大兔子 提交于 2019-11-29 15:34:43
I have problem when I try to display the image with full size. I tried to display image with wrap_content. But it is smaller real image. <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/screen1_logo" /> I go to the properties of this image and see some information: dimentions 211 x 74. Then I try to display image with fixed width and height. I see it's bigger. <ImageView android:layout_width="211px" android:layout_height="74px" android:src="@drawable/screen1_logo" /> is it right way? do we must to fix size to display image with full

dynamically add layout into getview method of adaptor in android

扶醉桌前 提交于 2019-11-29 15:34:20
问题 I want to display N number of imageview in every row of list view. Number of imageview depends on json parsing value. it can be 2 or 3 or 4 everytime when i fetch json from server. so I can not use static xml by using inflate.so i decided to create dynamic view in getview method and add N number of imageview into view I write following code but it still display only one imageview and horizontal scroll wont work at all.. any help is appreciated public class MyAdapter extends BaseAdapter{

Android : Load image from web URL [duplicate]

主宰稳场 提交于 2019-11-29 15:28:15
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Loading remote images I am developing an application where I have a list in which each row has an image, this image is loaded from a web URL. below is my code <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/list_row_img" android:layout_width="200dp" android:layout_height="200dp" />

Display image from URL - sizing and screen orientation problems

守給你的承諾、 提交于 2019-11-29 14:43:33
问题 I am trying to display an image from a URL, which may be larger than the screen dimensions. I have it kind of working, but I would like it to scale to fit the screen, and I also have problems when the screen orientation changes. The image is tiny, and I would like it to scale its width to the screen as well. (In both cases, I would like the image to fill the screen width with scrollbars (if necessary for height). Here is my ImageView: <ImageView android:id="@+id/ImageView01" android:layout

RecyclerView: how to catch the onClick on an ImageView?

ぃ、小莉子 提交于 2019-11-29 14:25:16
I have an ImageView in CardViews of my RecyclerView. I would like to catch the onClick on the ImageView, like I already did with the ListView. So, in the public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) I tried with: myViewHolder.imageView.setClickable(true); myViewHolder.imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d("TEST", "Clicked"); } but this was totally ignored. The following code is working: myViewHolder.imageView.setImageResource(R.drawable.star_yellow); What can I do? Here's what I do in my