drawable

Null Pointer Exception when Drawing an image

天大地大妈咪最大 提交于 2019-12-12 01:58:56
问题 I am having a problem with setting an ImageView image to an image which has been fetched from a URL. Here is the method used to turn the URL into a Drawable object: private Drawable LoadImage(String url){ try { InputStream is = (InputStream) new URL(url).getContent(); Drawable d = Drawable.createFromStream(is, "src"); return d; }catch (Exception e) { System.out.println("Exc="+e); return null; } } Here is the code to call the method: Drawable drawable = LoadImage("www.myurl.com/image.jpg");

Android: action_send put extra_stream from res/drawable folder causes crash

依然范特西╮ 提交于 2019-12-12 01:57:34
问题 I am creating a game, and trying to allow the user to share their win via text/facebook/etc. I am using the code below to grab an image from my res/drawable folder. I am pretty sure I am doing it right, but my app keeps crashing after I choose the send method (ex. facebook). Any help would be greatly appreciated. Intent ShareIntent = new Intent(android.content.Intent.ACTION_SEND); ShareIntent.setType("image/jpeg"); Uri winnerPic = Uri.parse("android.resource://com.poop.pals/" + R.drawable

NinePatchDrawable from Drawable.createFromPath or FileInputStream

孤人 提交于 2019-12-12 01:28:42
问题 I cannot get a nine patch drawable to work (i.e. it is stretching the nine patch image) when loading from either Drawable.createFromPath or from a number of other methods using an InputStream. Loading the same nine patch works fine when loading from when resources. Here's the methods I am trying: Button b = (Button) findViewById(R.id.Button01); Drawable d = null; //From Resources (WORKS!) d = getResources().getDrawable(R.drawable.test); //From Raw Resources (Doesn't Work) InputStream is =

Android Drawable Marker with Bitmap Text Overlay too Small

对着背影说爱祢 提交于 2019-12-11 23:36:46
问题 I am creating a Marker with text but the text is showing only 3 characters and very small and it is right of the bit map image. I want the text to go across the middle of the icon and it big font. I manually increased setFontsize to larger size did not work and also drawText width and height still did not work. private Drawable createMarkerIcon(Drawable backgroundImage, String text, int width, int height) { Bitmap canvasBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); /

NullPointerException in createBitmap() from View

孤者浪人 提交于 2019-12-11 19:44:19
问题 I am using the below code for getting a Bitmap from a View : private static Bitmap loadBitmapFromView(View yourView) { Bitmap snapshot = null; Drawable drawable = null; yourView.setDrawingCacheEnabled(true); yourView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); //Quality of the snpashot try { snapshot = Bitmap.createBitmap(yourView.getDrawingCache()); drawable = new BitmapDrawable(snapshot); } finally { yourView.setDrawingCacheEnabled(false); } return snapshot; } But I am getting

How to set an image in android app with sftp input stream?

匆匆过客 提交于 2019-12-11 15:12:35
问题 I'm using Android Studio to build an application. In this app, I want to get an image in a specific folder from a linux host using Jsch sftp , and set this new picture to an already-existing imageview. But unfortunately the picture doesn't show up. The following are the codes for this so far: MainActivity.java package com.example.picture_controller_2; import android.graphics.drawable.Drawable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.app

SetImageDrawable in a list view

醉酒当歌 提交于 2019-12-11 12:45:13
问题 In my list view, I want to make it so that it will change the drawable in the image view i made, but I get an error every time I run it. ImageView Player; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Player = (ImageView)findViewById(R.id.bob); setListAdapter(new ArrayAdapter<String>(this, R.layout.pointguards, PointGuards)); final ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() {

how to load a picture from my resource in webview?

筅森魡賤 提交于 2019-12-11 10:56:57
问题 I want to load a picture called map.png set in my drawable resource in the WebView. I found in another answer this suggestion webview.loadUrl("file://...") but I don't understand how to set it properly. I always get error that the requested file was not found. This is what I wrote `public class Map extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map);

Android Drawable setLevel(); not filling SeekBar appropriately

孤街浪徒 提交于 2019-12-11 10:18:35
问题 Okay so I've been able to customize a few SeekBar's to be used as a Bar Graph type of image, but since I need to be able to switch between a Green or Red Image (depending on certain values) which you can see below. The problem is that regardless of what value I use in the setLevel for the Drawable it doesn't fill appropriately (you can see the image below for an example since the green bar should be closer to the right based on the two values) Below is the code for the section that setups

Select Drawable file path

独自空忆成欢 提交于 2019-12-11 09:46:27
问题 I am developing an android application that receives data about events from a server. In a ListView I put the name and category of the event and a picture. My problem is: each category should have a specific picture. How do I choose which of the pictures in the drawable folder should be displayed? View v; /**I get this view from the parameters.**/ ImageView iconCategory = (ImageView) v .findViewById(R.id.category_icon); Drawable drawable = null; if (o.getCategoria().equals("category1")) { /*