Search Results

Search found 708 results on 29 pages for 'drawable'.

Page 5/29 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Android ListView with Custom List Selector causing Flickring problem

    - by y ramesh rao
    I'm setting a selector.xml to the ListView Selector : <item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/timeline_selected_rect"/> <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/timeline_selected_rect"/> <item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/timeline_selected_rect"/> but setting this is causing the TextView flickr over selection. this thing is not happening when the Default selector is used... whats wrong with this selector. I have even added android:cacheColorHint="#00000000" as provided info by some other blogs.

    Read the article

  • Android mapView ItemizedOverlay setFocus does not work properly

    - by Gaks
    Calling setFocus(null) on the ItemizedOverlay does not 'unfocus' current marker. According to the documentation: ... If the Item is not found, this is a no-op. You can also pass null to remove focus. Here's my code: MapItemizedOverlay public class MapItemizedOverlay extends ItemizedOverlay<OverlayItem> { private ArrayList<OverlayItem> items = new ArrayList<OverlayItem>(); public MapItemizedOverlay(Drawable defaultMarker) { super(defaultMarker); } public void addOverlay(OverlayItem overlay) { items.add(overlay); populate(); } @Override protected OverlayItem createItem(int i) { return items.get(i); } @Override public int size() { return items.size(); } } Creating map overlay and one marker: StateListDrawable youIcon = (StateListDrawable)getResources().getDrawable(R.drawable.marker_icon); int width = youIcon.getIntrinsicWidth(); int height = youIcon.getIntrinsicHeight(); youIcon.setBounds(-13, 0-height, -13+width, 0); GeoPoint location = new GeoPoint(40800816,-74122009); MapItemizedOverlay overlay = new MapItemizedOverlay(youIcon); OverlayItem item = new OverlayItem(location, "title", "snippet"); overlay.addOverlay(item); mapView.getOverlays().add(overlay); The R.drawable.marker_icon is defined as follows: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:drawable="@drawable/marker_selected" /> <item android:state_selected="true" android:drawable="@drawable/marker_selected" /> <item android:drawable="@drawable/marker_normal" /> </selector> Now, to test the setFocus() behavior I put the button on the activity window, with the following onClick listener: Button focusBtn = (Button)findViewById(R.id.focusbtn); focusBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for(Overlay ov : mapView.getOverlays()) { if(ov.getClass().getSimpleName().equals("MapItemizedOverlay") == true) { MapItemizedOverlay miv = (MapItemizedOverlay)ov; if(miv.getFocus() == null) miv.setFocus(miv.getItem(0)); else miv.setFocus(null); break; } } mapView.invalidate(); } }); The expected behavior is: clicking on the button toggles marker selection. It works only once - clicking it for the first time selects the marker, clicking it again does not de-select the marker. The most weird thing about it is that after calling setFocus(null), getFocus() also returns null - like the overlay has no focused item (I debugged it). But even after calling mapView.invalidate() the marker is still drawn in 'selected'(focused) state.

    Read the article

  • Android - MapView contained within a Listview

    - by Ryan
    Hello, Currently I am trying to place a MapView within a ListView. Has anyone had any success with this? Is it even possible? Here is my code: ListView myList = (ListView) findViewById(android.R.id.list); List<Map<String, Object>> groupData = new ArrayList<Map<String, Object>>(); Map<String, Object> curGroupMap = new HashMap<String, Object>(); groupData.add(curGroupMap); curGroupMap.put("ICON", R.drawable.back_icon); curGroupMap.put("NAME","Go Back"); curGroupMap.put("VALUE","By clicking here"); Iterator it = data.entrySet().iterator(); while (it.hasNext()) { //Get the key name and value for it Map.Entry pair = (Map.Entry)it.next(); String keyName = (String) pair.getKey(); String value = pair.getValue().toString(); if (value != null) { //Add the parents -- aka main categories curGroupMap = new HashMap<String, Object>(); groupData.add(curGroupMap); //Push the correct Icon if (keyName.equalsIgnoreCase("Phone")) curGroupMap.put("ICON", R.drawable.phone_icon); else if (keyName.equalsIgnoreCase("Housing")) curGroupMap.put("ICON", R.drawable.house_icon); else if (keyName.equalsIgnoreCase("Website")) curGroupMap.put("ICON", R.drawable.web_icon); else if (keyName.equalsIgnoreCase("Area Snapshot")) curGroupMap.put("ICON", R.drawable.camera_icon); else if (keyName.equalsIgnoreCase("Overview")) curGroupMap.put("ICON", R.drawable.overview_icon); else if (keyName.equalsIgnoreCase("Location")) curGroupMap.put("ICON", R.drawable.map_icon); else curGroupMap.put("ICON", R.drawable.icon); //Pop on the Name and Value curGroupMap.put("NAME", keyName); curGroupMap.put("VALUE", value); } } curGroupMap = new HashMap<String, Object>(); groupData.add(curGroupMap); curGroupMap.put("ICON", R.drawable.back_icon); curGroupMap.put("NAME","Go Back"); curGroupMap.put("VALUE","By clicking here"); //Set up adapter mAdapter = new SimpleAdapter( mContext, groupData, R.layout.exp_list_parent, new String[] { "ICON", "NAME", "VALUE" }, new int[] { R.id.photoAlbumImg, R.id.rowText1, R.id.rowText2 } ); myList.setAdapter(mAdapter); //Bind the adapter to the list Thanks in advance for your help!!

    Read the article

  • about the JOGL 2 problem

    - by Chuchinyi
    Please some help me about the JOGL 2 problem(Sorry for previous error format). I complied JOGL2Template.java ok. but execut it with following error. D:\java\java\jogl>javac JOGL2Template.java <== compile ok D:\java\java\jogl>java JOGL2Template <== execute error Exception in thread "main" java.lang.ExceptionInInitializerError at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:1176) at JOGL2Template.<init>(JOGL2Template.java:24) at JOGL2Template.main(JOGL2Template.java:57) Caused by: java.lang.SecurityException: no certificate for gluegen-rt.dll in D:\ java\lib\gluegen-rt-natives-windows-i586.jar at com.jogamp.common.util.JarUtil.validateCertificate(JarUtil.java:350) at com.jogamp.common.util.JarUtil.validateCertificates(JarUtil.java:324) at com.jogamp.common.util.cache.TempJarCache.validateCertificates(TempJa rCache.java:328) at com.jogamp.common.util.cache.TempJarCache.bootstrapNativeLib(TempJarC ache.java:283) at com.jogamp.common.os.Platform$3.run(Platform.java:308) at java.security.AccessController.doPrivileged(Native Method) at com.jogamp.common.os.Platform.loadGlueGenRTImpl(Platform.java:298) at com.jogamp.common.os.Platform.<clinit>(Platform.java:207) ... 3 more there is JOGL2Template.java source code: import java.awt.Dimension; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import com.jogamp.opengl.util.FPSAnimator; import javax.swing.JFrame; /* * JOGL 2.0 Program Template For AWT applications */ public class JOGL2Template extends JFrame implements GLEventListener { private static final int CANVAS_WIDTH = 640; // Width of the drawable private static final int CANVAS_HEIGHT = 480; // Height of the drawable private static final int FPS = 60; // Animator's target frames per second // Constructor to create profile, caps, drawable, animator, and initialize Frame public JOGL2Template() { // Get the default OpenGL profile that best reflect your running platform. GLProfile glp = GLProfile.getDefault(); // Specifies a set of OpenGL capabilities, based on your profile. GLCapabilities caps = new GLCapabilities(glp); // Allocate a GLDrawable, based on your OpenGL capabilities. GLCanvas canvas = new GLCanvas(caps); canvas.setPreferredSize(new Dimension(CANVAS_WIDTH, CANVAS_HEIGHT)); canvas.addGLEventListener(this); // Create a animator that drives canvas' display() at 60 fps. final FPSAnimator animator = new FPSAnimator(canvas, FPS); addWindowListener(new WindowAdapter() { // For the close button @Override public void windowClosing(WindowEvent e) { // Use a dedicate thread to run the stop() to ensure that the // animator stops before program exits. new Thread() { @Override public void run() { animator.stop(); System.exit(0); } }.start(); } }); add(canvas); pack(); setTitle("OpenGL 2 Test"); setVisible(true); animator.start(); // Start the animator } public static void main(String[] args) { new JOGL2Template(); } @Override public void init(GLAutoDrawable drawable) { // Your OpenGL codes to perform one-time initialization tasks // such as setting up of lights and display lists. } @Override public void display(GLAutoDrawable drawable) { // Your OpenGL graphic rendering codes for each refresh. } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { // Your OpenGL codes to set up the view port, projection mode and view volume. } @Override public void dispose(GLAutoDrawable drawable) { // Hardly used. } }

    Read the article

  • JOGL2 test compiles, but doesn't execute - help?

    - by Chuchinyi
    I have a problem with JOGL2. My JOGL2Template.java compiles fine, but executing it results in the following error: D:\java\java\jogl>javac JOGL2Template.java <== compile ok D:\java\java\jogl>java JOGL2Template <== execute error Exception in thread "main" java.lang.ExceptionInInitializerError at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:1176) at JOGL2Template.<init>(JOGL2Template.java:24) at JOGL2Template.main(JOGL2Template.java:57) Caused by: java.lang.SecurityException: no certificate for gluegen-rt.dll in D:\ java\lib\gluegen-rt-natives-windows-i586.jar at com.jogamp.common.util.JarUtil.validateCertificate(JarUtil.java:350) at com.jogamp.common.util.JarUtil.validateCertificates(JarUtil.java:324) at com.jogamp.common.util.cache.TempJarCache.validateCertificates(TempJa rCache.java:328) at com.jogamp.common.util.cache.TempJarCache.bootstrapNativeLib(TempJarC ache.java:283) at com.jogamp.common.os.Platform$3.run(Platform.java:308) at java.security.AccessController.doPrivileged(Native Method) at com.jogamp.common.os.Platform.loadGlueGenRTImpl(Platform.java:298) at com.jogamp.common.os.Platform.<clinit>(Platform.java:207) ... 3 more Here is the JOGL2Template.java source code: import java.awt.Dimension; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import com.jogamp.opengl.util.FPSAnimator; import javax.swing.JFrame; /* * JOGL 2.0 Program Template For AWT applications */ public class JOGL2Template extends JFrame implements GLEventListener { private static final int CANVAS_WIDTH = 640; // Width of the drawable private static final int CANVAS_HEIGHT = 480; // Height of the drawable private static final int FPS = 60; // Animator's target frames per second // Constructor to create profile, caps, drawable, animator, and initialize Frame public JOGL2Template() { // Get the default OpenGL profile that best reflect your running platform. GLProfile glp = GLProfile.getDefault(); // Specifies a set of OpenGL capabilities, based on your profile. GLCapabilities caps = new GLCapabilities(glp); // Allocate a GLDrawable, based on your OpenGL capabilities. GLCanvas canvas = new GLCanvas(caps); canvas.setPreferredSize(new Dimension(CANVAS_WIDTH, CANVAS_HEIGHT)); canvas.addGLEventListener(this); // Create a animator that drives canvas' display() at 60 fps. final FPSAnimator animator = new FPSAnimator(canvas, FPS); addWindowListener(new WindowAdapter() { // For the close button @Override public void windowClosing(WindowEvent e) { // Use a dedicate thread to run the stop() to ensure that the // animator stops before program exits. new Thread() { @Override public void run() { animator.stop(); System.exit(0); } }.start(); } }); add(canvas); pack(); setTitle("OpenGL 2 Test"); setVisible(true); animator.start(); // Start the animator } public static void main(String[] args) { new JOGL2Template(); } @Override public void init(GLAutoDrawable drawable) { // Your OpenGL codes to perform one-time initialization tasks // such as setting up of lights and display lists. } @Override public void display(GLAutoDrawable drawable) { // Your OpenGL graphic rendering codes for each refresh. } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { // Your OpenGL codes to set up the view port, projection mode and view volume. } @Override public void dispose(GLAutoDrawable drawable) { // Hardly used. } } Any ideas what might be the cause of these errors?

    Read the article

  • add an image in listview

    - by danish
    Hi I would like to add more images in my list view as this code below only displays image 1 and 2 continuously in each row. What I want to do is display a different image for each different row. Here is mycode below; Thanks for any help. I am not good at java please change the code where necessary and I can then refer to it. public class starters extends ListActivity { private static class EfficientAdapter extends BaseAdapter { private LayoutInflater mInflater; private Bitmap mIcon1; private Bitmap mIcon2; private Bitmap mIcon3; private Bitmap mIcon4; private Bitmap mIcon5; private Bitmap mIcon6; private Bitmap mIcon7; private Bitmap mIcon8; private Bitmap mIcon9; private Bitmap mIcon10; public EfficientAdapter(Context context) { // Cache the LayoutInflate to avoid asking for a new one each time. mInflater = LayoutInflater.from(context); // Icons bound to the rows. mIcon1 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters1); mIcon2 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters2); mIcon3 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters3); mIcon4 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters4); mIcon5 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters5); mIcon6 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters6); mIcon7 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters7); mIcon8 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters8); mIcon9 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters9); mIcon10 = BitmapFactory.decodeResource(context.getResources(), R.drawable.starters10); } public int getCount() { return DATA.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { // A ViewHolder keeps references to children views to avoid unneccessary calls // to findViewById() on each row. ViewHolder holder; // When convertView is not null, we can reuse it directly, there is no need // to reinflate it. We only inflate a new View when the convertView supplied // by ListView is null. if (convertView == null) { convertView = mInflater.inflate(R.layout.starters, null); // Creates a ViewHolder and store references to the two children views // we want to bind data to. holder = new ViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.text01); holder.text = (TextView) convertView.findViewById(R.id.secondLine); holder.icon = (ImageView) convertView.findViewById(R.id.icon01); convertView.setTag(holder); } else { // Get the ViewHolder back to get fast access to the TextView // and the ImageView. holder = (ViewHolder) convertView.getTag(); } // Bind the data efficiently with the holder. holder.text.setText(DATA[position]); holder.icon.setImageBitmap((position & 1) ==1 ? mIcon1 : mIcon2); return convertView; } static class ViewHolder { TextView text; ImageView icon; } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new EfficientAdapter(this)); } private static final String[] DATA = { "Original nachos", "Toasted chicken and cheese quesadillas", "Chicken, lime and coriander nachos", "Spicy bean and cheese quesadillas", "Tuna and corn quesadillas", "Cheesy bean and sweetcorn nachos", "Crispy chicken, avocado and lime salad", "Beef and baby corn tostada", "Spicy mexican rice with chicken and prawns", "Chilli potato boats"}; }

    Read the article

  • Binary XML file <line 20>: Error inflating class <Unknown>

    - by user2750644
    <RelativeLayout 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:layout_gravity="top|left|right" android:background="@drawable/bg" tools:context=".MainActivity" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="50dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:src="@drawable/top_red_bar" android:layout_alignParentLeft="true" android:paddingLeft="0dp" android:scaleType="centerCrop" /> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="45dp" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_alignTop="@+id/imageView1" android:layout_centerHorizontal="true" android:src="@drawable/job_bar" /> <ImageView android:id="@+id/imageView3" android:layout_width="238dp" android:layout_height="50dp" android:layout_below="@+id/imageView1" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_marginTop="123dp" android:src="@drawable/button" android:alpha="0.85" android:onClick="myhandler"/> <ImageView android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="50dp" android:layout_alignParentLeft="true" android:layout_below="@+id/imageView3" android:layout_marginTop="24dp" android:src="@drawable/button" android:alpha="0.85"/> <ImageView android:id="@+id/imageView5" android:layout_width="35dp" android:layout_height="45dp" android:layout_above="@+id/imageView4" android:layout_alignLeft="@+id/imageView3" android:layout_marginLeft="21dp" android:src="@drawable/employer" /> <ImageView android:id="@+id/imageView6" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignLeft="@+id/imageView5" android:layout_alignTop="@+id/imageView4" android:src="@drawable/jobseekers" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/imageView5" android:layout_centerHorizontal="true" android:layout_marginLeft="18dp" android:layout_toRightOf="@+id/imageView6" android:text="Employer" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#ffffff" android:textStyle="bold" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_alignTop="@+id/imageView4" android:text="Job Seekers" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#ffffff" android:textStyle="bold" /> </RelativeLayout> My app gets crashed with error statement Binary XML file <line 20>: Error inflating class <Unknown>. Why does this happen?? Could anyone fix this? And interestingly, when I remove all code except background, it works!!!

    Read the article

  • Updated - Having trouble making a circled button in android

    - by user3641545
    I'm trying to use an image as a button. The image is an oval/circle, so when I set it as the background there's basically a black box with the image on top of it. How can I fix this? This is the fragment main xml: <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.example1.MainActivity$PlaceholderFragment" > <ImageButton android:id="@+id/hardButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="@drawable/hard_button_clickable" android:onClick="hardButton" android:text="@string/button_hard" android:textColor="#ffff00" android:textSize="50sp" /> </RelativeLayout> This is the hard button xml: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/hard_button_img" android:state_focused="true" android:state_pressed="false"/> <item android:drawable="@drawable/hard_button_img" android:state_focused="true" android:state_pressed="true"/> <item android:drawable="@drawable/hard_button_img"/> </selector> Here's the problem in the app: http://i.gyazo.com/a7f3b25341ebf4146d294df1f5660e99.png I've tried setting background to null and setting src to my image file. Nothing changed. Thanks. e; Here's the actual PNG: http://tinypic.com/r/av3cli/8 e; Still looking for help with this!

    Read the article

  • Android: 2D. OpenGl or android.graphics.drawable?

    - by DroidIn.net
    I'm working with my friend on our first Android game. Basic idea is that every frame the whole surface is redrawn (1 large bitmap) which then sprinkled all over with large number of particles which produces effect of soapy bubbles where there's a pool of about 20 bitmaps which randomly gets picked to produce illusion that all bubbles (between 200 - 300) are all different. The math engine is in C (JNI) and currently all drawing is done using android.graphics package very similar (since that was the example I was using) to Lunar Lander. It works but animation is somewhat jerky and I can feel by temperature of my phone that it is very busy. Will we benefit from switching to OpenGL? And as a bonus question: what would be a good way to optimize the drawing mechanism (Lunar Lander like) we have now?

    Read the article

  • How do I set streetView in my mapview

    - by John
    I an working on an android project whereby i need to set my map to zoom in and show a more detailed view of my map, like the streets of where i want my coordinates to triangulate. The problem is in Mapview class, setStreetView is deprecated, wat is the alternative? This is how setStreetView looks when i use it. package com.HelloMapView; import java.util.List; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; import android.app.Activity; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.widget.LinearLayout; public class HelloMapView extends MapActivity { MapView mapview; LinearLayout linearlayout; List<Overlay> mapOverlay; Drawable drawable; HelloItemizedOverlay itemizedOverlay; @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapview=(MapView)findViewById(R.id.mapview); mapview.setBuiltInZoomControls(true); mapview.setStreetView(true); mapOverlay=mapview.getOverlays(); drawable=this.getResources().getDrawable(R.drawable.androidmarker); itemizedOverlay=new HelloItemizedOverlay(drawable); GeoPoint geoPoint=new GeoPoint(19240000,-99120000); OverlayItem overlayitem=new OverlayItem(geoPoint,"",""); itemizedOverlay.addoverlay(overlayitem); mapOverlay.add(itemizedOverlay); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } this does not work it only shows square boxes with no map at all

    Read the article

  • Null reading in stream images? Unable to start activity ComponentInfo

    - by lasmith
    I have reviewed a lot of similar questions regarding not being able to launch an activity but they don't seem to quite match my problem. I am working on a simple black jack game but its force quitting. I suspect there is a problem with loading up the card png images I have. Stepping through the debugger it crashes right while in the resetGame() function. I'm sure I am doing something dumb. My Logcat: 10-15 20:21:43.309: E/AndroidRuntime(2863): FATAL EXCEPTION: main 10-15 20:21:43.309: E/AndroidRuntime(2863): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smith.blackjack/com.smith.blackjack.Main}: java.lang.NullPointerException 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.ActivityThread.access$600(ActivityThread.java:130) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.os.Handler.dispatchMessage(Handler.java:99) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.os.Looper.loop(Looper.java:137) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.ActivityThread.main(ActivityThread.java:4745) 10-15 20:21:43.309: E/AndroidRuntime(2863): at java.lang.reflect.Method.invokeNative(Native Method) 10-15 20:21:43.309: E/AndroidRuntime(2863): at java.lang.reflect.Method.invoke(Method.java:511) 10-15 20:21:43.309: E/AndroidRuntime(2863): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 10-15 20:21:43.309: E/AndroidRuntime(2863): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-15 20:21:43.309: E/AndroidRuntime(2863): at dalvik.system.NativeStart.main(Native Method) 10-15 20:21:43.309: E/AndroidRuntime(2863): Caused by: java.lang.NullPointerException 10-15 20:21:43.309: E/AndroidRuntime(2863): at com.smith.blackjack.DeckOfCards.<init>(DeckOfCards.java:17) 10-15 20:21:43.309: E/AndroidRuntime(2863): at com.smith.blackjack.Main.resetGame(Main.java:98) 10-15 20:21:43.309: E/AndroidRuntime(2863): at com.smith.blackjack.Main.onCreate(Main.java:67) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.Activity.performCreate(Activity.java:5008) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 10-15 20:21:43.309: E/AndroidRuntime(2863): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 10-15 20:21:43.309: E/AndroidRuntime(2863): ... 11 more My androidmanifest: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.smith.blackjack" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".Main" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> Here is my Main.java package com.smith.blackjack; import android.os.Bundle; import android.app.Activity; import android.content.res.AssetManager; import android.graphics.drawable.Drawable; import java.io.IOException; import java.io.InputStream; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView; public class Main extends Activity { private ImageView dealerCard0; private ImageView dealerCard1; private ImageView dealerCard2; private ImageView dealerCard3; private ImageView playerCard0; private ImageView playerCard1; private ImageView playerCard2; private ImageView playerCard3; private ImageView imgResult; private Button btnDeal; private Button btnDraw; private Button btnHold; private DeckOfCards deckOfCards; private int[] dealerValues; private int dealerSum; private int dealerCardNumber; private int[] playerValues; private int playerSum; private int playerCardNumber; private InputStream dealerHiddenCard; private Card dealerCard; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); dealerCard0 = (ImageView) findViewById(R.id.dealerCard0); dealerCard1 = (ImageView) findViewById(R.id.dealerCard1); dealerCard2 = (ImageView) findViewById(R.id.dealerCard2); dealerCard3 = (ImageView) findViewById(R.id.dealerCard3); playerCard0 = (ImageView) findViewById(R.id.playerCard0); playerCard1 = (ImageView) findViewById(R.id.playerCard1); playerCard2 = (ImageView) findViewById(R.id.playerCard2); playerCard3 = (ImageView) findViewById(R.id.playerCard3); imgResult = (ImageView) findViewById(R.id.imgResult); btnDeal = (Button) findViewById(R.id.deal); btnDraw = (Button) findViewById(R.id.draw); btnHold = (Button) findViewById(R.id.hold); btnDeal.setOnClickListener(btnDealListener); btnDraw.setOnClickListener(btnDrawListener); btnHold.setOnClickListener(btnHoldListener); resetGame(); } private void resetGame(){ AssetManager assets = getAssets(); dealerValues = new int[4]; playerValues = new int[4]; dealerSum = 0; playerSum = 0; dealerCardNumber = 0; playerCardNumber = 0; for (int i = 0; i < 4; i++) { dealerValues[i] = 0; playerValues[i] = 0; } try { InputStream stream = assets.open("cardback.png"); // stream = assets.open("cardback.png"); Drawable cardImage = Drawable.createFromStream(stream, null); dealerCard0.setImageDrawable(cardImage); dealerCard1.setImageDrawable(cardImage); dealerCard2.setImageDrawable(cardImage); dealerCard3.setImageDrawable(cardImage); playerCard0.setImageDrawable(cardImage); playerCard1.setImageDrawable(cardImage); playerCard2.setImageDrawable(cardImage); playerCard3.setImageDrawable(cardImage); imgResult.setImageDrawable(cardImage); deckOfCards = new DeckOfCards(); deckOfCards.shuffle(); assets.close(); } catch (IOException e){ Log.e("Reset Game", "Error Loading", e); } } public OnClickListener btnDealListener = new OnClickListener() { // @Override public void onClick(View v) { try { AssetManager assets = getAssets(); InputStream stream; // first player card Card newCard; newCard = deckOfCards.dealCard(); playerValues[playerCardNumber] = newCard.faceValue; playerCardNumber++; stream = assets.open(newCard.File); Drawable cardImage = Drawable.createFromStream(stream, newCard.File); playerCard0.setImageDrawable(cardImage); assets.close(); // second player card newCard = deckOfCards.dealCard(); playerValues[playerCardNumber] = newCard.faceValue; playerCardNumber++; stream = assets.open(newCard.File); cardImage = Drawable.createFromStream(stream, newCard.File); playerCard1.setImageDrawable(cardImage); assets.close(); // first dealer card hidden newCard = deckOfCards.dealCard(); dealerCard = newCard; dealerValues[dealerCardNumber] = newCard.faceValue; dealerCardNumber++; dealerHiddenCard = assets.open(newCard.File); stream = assets.open("cardback.png"); cardImage = Drawable.createFromStream(stream, "cardback"); dealerCard0.setImageDrawable(cardImage); assets.close(); // second dealer card open newCard = deckOfCards.dealCard(); dealerValues[dealerCardNumber] = newCard.faceValue; dealerCardNumber++; stream = assets.open(newCard.File); cardImage = Drawable.createFromStream(stream, newCard.File); dealerCard1.setImageDrawable(cardImage); assets.close(); } catch (IOException e){ Log.e("Deal", "Error Loading", e); } }; }; public OnClickListener btnDrawListener = new OnClickListener() { // @Override public void onClick(View v) { try { AssetManager assets = getAssets(); InputStream stream; // get next player card Card newCard; newCard = deckOfCards.dealCard(); playerValues[playerCardNumber] = newCard.faceValue; playerCardNumber++; stream = assets.open(newCard.File); Drawable cardImage = Drawable.createFromStream(stream, newCard.File); switch (playerCardNumber){ case 3: playerCard2.setImageDrawable(cardImage); case 4: playerCard3.setImageDrawable(cardImage); } assets.close(); } catch (IOException e){ Log.e("Draw", "Error Loading", e); } }; }; public OnClickListener btnHoldListener = new OnClickListener() { // @Override public void onClick(View v) { Drawable cardImage; // evaluate player hand playerSum = evaluate(playerValues); if (playerSum > 21){ // player losses } // flip over the dealer hidden card cardImage = Drawable.createFromStream(dealerHiddenCard, dealerCard.File); Card newCard; InputStream stream; AssetManager assets = getAssets(); for (int i=2; i<4; i++){ dealerSum = evaluate(dealerValues); if (dealerSum < 16 ) { newCard = deckOfCards.dealCard(); dealerValues[dealerCardNumber] = newCard.faceValue; dealerCardNumber++; try { stream = assets.open(newCard.File); cardImage = Drawable.createFromStream(stream, newCard.File); switch (dealerCardNumber){ case 3: dealerCard2.setImageDrawable(cardImage); case 4: dealerCard3.setImageDrawable(cardImage); } assets.close(); } catch (IOException e){ Log.e("Draw", "Error Loading", e); } if (dealerSum < playerSum) { // player wins } if (dealerSum > playerSum){ // dealer wins } if (dealerSum == playerSum){ // it is a draw } } } }; }; public int evaluate (int[]values) { int sumCards = 0; for (int i = 0; i < 4; i++){ sumCards += values[i]; } if (sumCards > 21) { for (int i = 0; i < 4; i++){ if (values[i] == 11) { values[i] = 1; sumCards -= 10; continue; } } } return sumCards; } } My DeckOfCards class: package com.smith.blackjack; import java.util.Random; public class DeckOfCards { private Card [] deck; private int currentCard; private static final int NUMBER_OF_CARDS = 52; private static final Random randomNumbers = new Random(); public DeckOfCards () { deck = new Card[NUMBER_OF_CARDS]; currentCard = 0 ; for(int count = 0; count < deck.length; count++) { deck[count].faceValue = count + 1; } } public void shuffle () { currentCard = 0; for (int first = 0; first < deck.length; first ++){ int second = randomNumbers.nextInt(NUMBER_OF_CARDS); int temp = deck[first].faceValue; deck[first].faceValue=deck[second].faceValue; deck[second].faceValue = temp; } } public Card dealCard(){ Card temp = new Card(); temp.faceValue = 0; temp.File = ""; if(currentCard < deck.length) { temp.faceValue = deck[currentCard].faceValue / 4; int suit = deck[currentCard].faceValue % 4; String suitString = ""; switch (suit){ case 0: suitString = "c"; case 1: suitString = "d"; case 2: suitString = "h"; case 3: suitString = "s"; } Integer face = temp.faceValue / 4 ; String faceString = face.toString(); temp.File = faceString + suitString + ".png"; switch (temp.faceValue){ case 11: temp.faceValue = 10; case 12: temp.faceValue = 10; case 13: temp.faceValue = 10; } return temp; } else return temp; } }

    Read the article

  • how do i add images from drable folder instead of url in this code

    - by hayya anam
    i used the following URL https://github.com/jgilfelt/android-mapviewballoons source in my application is show image by using url how do i give images form my own drawable folder?? i found this mapview url which show images inbaloon but is show images by url i wanna show myown iamges how i do? howi give my own images from my folder public class CustomMap extends MapActivity { MapView mapView; List<Overlay> mapOverlays; Drawable drawable; Drawable drawable2; CustomItemizedOverlay<CustomOverlayItem> itemizedOverlay; CustomItemizedOverlay<CustomOverlayItem> itemizedOverlay2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapOverlays = mapView.getOverlays(); // first overlay drawable = getResources().getDrawable(R.drawable.marker); itemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView); GeoPoint point = new GeoPoint((int)(51.5174723*1E6),(int)(-0.0899537*1E6)); CustomOverlayItem overlayItem = new CustomOverlayItem(point, "Tomorrow Never Dies (1997)", "(M gives Bond his mission in Daimler car)", "http://ia.media-imdb.com/images /M/MV5BMTM1MTk2ODQxNV5BMl5BanBnXkFtZTcwOTY5MDg0NA@@._V1._SX40_CR0,0,40,54_.jpg"); itemizedOverlay.addOverlay(overlayItem); GeoPoint point2 = new GeoPoint((int)(51.515259*1E6),(int)(-0.086623*1E6)); CustomOverlayItem overlayItem2 = new CustomOverlayItem(point2, "GoldenEye (1995)", "(Interiors Russian defence ministry council chambers in St Petersburg)", "http://ia.media-imdb.com/images M/MV5BMzk2OTg 4MTk1NF5BMl5BanBnXkFtZTcwNjExNTgzNA@@._V1._SX40_CR0,0,40,54_.jpg"); itemizedOverlay.addOverlay(overlayItem2); mapOverlays.add(itemizedOverlay); // second overlay drawable2 = getResources().getDrawable(R.drawable.marker2); itemizedOverlay2 = new CustomItemizedOverlay<CustomOverlayItem> (drawable2, mapView); GeoPoint point3 = new GeoPoint((int)(51.513329*1E6),(int)(-0.08896*1E6)); CustomOverlayItem overlayItem3 = new CustomOverlayItem(point3, "Sliding Doors (1998)", "(interiors)", null); itemizedOverlay2.addOverlay(overlayItem3); GeoPoint point4 = new GeoPoint((int)(51.51738*1E6),(int)(-0.08186*1E6)); CustomOverlayItem overlayItem4 = new CustomOverlayItem(point4, "Mission: Impossible (1996)", "(Ethan & Jim cafe meeting)", "http://ia.media-imdb.com/images /M/MV5BMjAyNjk5Njk0MV 5BMl5BanBnXkFtZTcwOTA4MjIyMQ@@._V1._SX40_CR0,0,40,54_.jpg"); itemizedOverlay2.addOverlay(overlayItem4); mapOverlays.add(itemizedOverlay2); final MapController mc = mapView.getController(); mc.animateTo(point2); mc.setZoom(16); } @Override protected boolean isRouteDisplayed() { return false; } }

    Read the article

  • Android hdpi resource load problem

    - by user357366
    good day we are developing game for android and have some trouble with resource loading on high dpi devices. our resources are located in res/drawable directory on a standart dpi device the game work properly, but on hdpi (tested on HTC Desire) all resources which located in res/drawable-hdpi load are loaded correctly, but the resources which miss in drawable-hdpi directory but present in res/drawable are ignored but everything works fine on the virtual device with hdpi. does anybody encounter this problem and know how to solve it?

    Read the article

  • Android Animate Rotate

    - by oriharel
    I did some digging in Android code, and saw the use of in the indeterminate progress bar. after trying to create my own drawable with this tag: <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/spinner_pia" android:pivotX="50%" android:pivotY="50%" android:framesCount="12" android:frameDuration="100" /> I get an error: "No resource identifier found for attribute 'frameDuration' in package 'android'" - which means that frameDuration is a private attribute. Is there a way to use this "animate-rotate" feature? My task is to replace the system's default indeterminate progress bar. I'd like to do it with as little code as possible (just change few attributes if possible). Using the ProgressBar view, setting: android:indeterminateOnly="true" android:indeterminateBehavior="cycle" android:indeterminateDuration="3500" android:indeterminateDrawable="@drawable/pia_sivuvator" and point "@drawable/pia_sivuvator" to that object would've make my task as elegant as they come but I'm stuck on those private attributes. help?

    Read the article

  • ListView slow performance

    - by Mohamed Hemdan
    I've created a list of recipes using Listview/customcursoradapter. A custom layout includes a photo for the recipe , Now I've some problems with the performance of viewing and scrolling the Listview although it has only 10 records (Target is 150). sometimes i get this error java.lang.OutOfMemoryError: bitmap size exceeds VM budget , I've tried to implement the Async task but i failed to do it. Is there any way i can overcome this problem? Your help is highly appreciated !! Here is my GetView method public View getView(int position, View convertView, ViewGroup parent) { View row = super.getView(position, convertView, parent); Cursor cursbbn = getCursor(); if (row == null) { LayoutInflater inflater = (LayoutInflater) localContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.listtype, null); } String Title = cursbbn.getString(2); String SandID=cursbbn.getString(1); String Readyin = cursbbn.getString(4); String Faovoites=cursbbn.getString(8); TextView titler=(TextView)row.findViewById(R.id.listmaintitle); TextView readyinr=(TextView)row.findViewById(R.id.listreadyin); int colorPos = position % colors.length; row.setBackgroundColor(colors[colorPos]); titler.setText(Title); readyinr.setText(Readyin); ImageView picture = (ImageView) row.findViewById(R.id.imageView1); Bitmap bitImg1 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0001); Bitmap bitImg2 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0002); Bitmap bitImg3 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0003); Bitmap bitImg4 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0004); Bitmap bitImg5 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0005); Bitmap bitImg6 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0006); Bitmap bitImg7 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0007); Bitmap bitImg8 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0008); Bitmap bitImg9 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0009); Bitmap bitImg10 = BitmapFactory.decodeResource(localContext.getResources(), R.drawable.rec0010); if(SandID.contentEquals("0001")) picture.setImageBitmap(getRoundedCornerImage(bitImg1)); if(SandID.contentEquals("0002")) picture.setImageBitmap(getRoundedCornerImage(bitImg2)); if(SandID.contentEquals("0003")) picture.setImageBitmap(getRoundedCornerImage(bitImg3)); if(SandID.contentEquals("0004")) picture.setImageBitmap(getRoundedCornerImage(bitImg4)); if(SandID.contentEquals("0005")) picture.setImageBitmap(getRoundedCornerImage(bitImg5)); if(SandID.contentEquals("0006")) picture.setImageBitmap(getRoundedCornerImage(bitImg6)); if(SandID.contentEquals("0007")) picture.setImageBitmap(getRoundedCornerImage(bitImg7)); if(SandID.contentEquals("0008")) picture.setImageBitmap(getRoundedCornerImage(bitImg8)); if(SandID.contentEquals("0009")) picture.setImageBitmap(getRoundedCornerImage(bitImg9)); if(SandID.contentEquals("0010")) picture.setImageBitmap(getRoundedCornerImage(bitImg10)); return row; } And This is the error : 05-02 03:11:55.898: E/AndroidRuntime(376): FATAL EXCEPTION: main 05-02 03:11:55.898: E/AndroidRuntime(376): java.lang.OutOfMemoryError: bitmap size exceeds VM budget 05-02 03:11:55.898: E/AndroidRuntime(376): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:359) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:385) 05-02 03:11:55.898: E/AndroidRuntime(376): at master.chef.mediamaster.AlternateRowCursorAdapter.getView(AlternateRowCursorAdapter.java:83) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.widget.AbsListView.obtainView(AbsListView.java:1409) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.widget.ListView.makeAndAddView(ListView.java:1745) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.widget.ListView.fillUp(ListView.java:700) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.widget.ListView.fillGap(ListView.java:646) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3399) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.widget.AbsListView.onTouchEvent(AbsListView.java:2233) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.widget.ListView.onTouchEvent(ListView.java:3446) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.View.dispatchTouchEvent(View.java:3885) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 05-02 03:11:55.898: E/AndroidRuntime(376): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691) 05-02 03:11:55.898: E/AndroidRuntime(376): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.app.Activity.dispatchTouchEvent(Activity.java:2096) 05-02 03:11:55.898: E/AndroidRuntime(376): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.os.Handler.dispatchMessage(Handler.java:99) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.os.Looper.loop(Looper.java:123) 05-02 03:11:55.898: E/AndroidRuntime(376): at android.app.ActivityThread.main(ActivityThread.java:3683) 05-02 03:11:55.898: E/AndroidRuntime(376): at java.lang.reflect.Method.invokeNative(Native Method) 05-02 03:11:55.898: E/AndroidRuntime(376): at java.lang.reflect.Method.invoke(Method.java:507) 05-02 03:11:55.898: E/AndroidRuntime(376): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 05-02 03:11:55.898: E/AndroidRuntime(376): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 05-02 03:11:55.898: E/AndroidRuntime(376): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • Android orientation change causes ImageView to dissapear

    - by Jarrod Smith
    Below is my layout for the row template in a SimpleCursorAdapter. The ImageView with id next_arrow disappears on orientation change. If I replace @drawable/arrow with @drawable/icon (copy of the standard sym_def_app_icon) it works fine. I thought it might be somehow related to the icons being of different dimensions, but I resized @drawable/icon to be the exact same dimensions as the arrow and it still worked fine while the arrow didn't. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="90dp" android:background="@drawable/product_list_divider" android:paddingTop="10dp"> <ImageView android:src="@drawable/ninja_20_65" android:id="@+id/category_icon" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="3dp"/> <LinearLayout android:orientation="vertical" android:layout_weight="5" android:layout_width="0dp" android:layout_height="wrap_content"> <TextView android:id="@+id/category_name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Name" style="@style/CategoryHeading" android:layout_marginTop="5dp"/> <TextView android:id="@+id/category_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Description" style="@style/CategoryDescription"/> </LinearLayout> <ImageView android:src="@drawable/arrow" android:layout_weight="1" android:layout_width="0dp" android:layout_marginRight="10dp" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:id="@+id/next_arrow"/> </LinearLayout>

    Read the article

  • Multiple screen support in android?

    - by Yugesh
    In my application have six buttons,the screen size is 4.65" 720p(720X1280 : xhdpi),device take this resolution from normal layout folder.when i run it in device.it display like the image am shown below.how to set this six buttons fit to the screen according to layout width and height.I don't know how to do.Can any one know please help me to solve this problem. My XML coding <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/home_xml" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" > <Button android:id="@+id/btn_login" android:layout_width="101dp" android:layout_height="193dp" android:layout_alignParentLeft="true" android:layout_below="@+id/imageView1" android:layout_marginLeft="4dp" android:layout_marginTop="78dp" android:background="@drawable/login_button" /> <Button android:id="@+id/btn_order" android:layout_width="101dp" android:layout_height="wrap_content" android:layout_alignBottom="@+id/btn_login" android:layout_alignTop="@+id/btn_login" android:layout_marginLeft="3dp" android:layout_toRightOf="@+id/btn_login" android:background="@drawable/order_button" /> <Button android:id="@+id/btn_abtus" android:layout_width="101dp" android:layout_height="wrap_content" android:layout_alignBottom="@+id/btn_order" android:layout_alignTop="@+id/btn_order" android:layout_marginLeft="3dp" android:layout_toRightOf="@+id/btn_order" android:background="@drawable/aboutus_button" /> <Button android:id="@+id/btn_outlet" android:layout_width="100dp" android:layout_height="198dp" android:layout_alignLeft="@+id/btn_login" android:layout_alignRight="@+id/btn_login" android:layout_below="@+id/btn_login" android:background="@drawable/outlets_button" /> <Button android:id="@+id/btn_feedback" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/btn_outlet" android:layout_alignLeft="@+id/btn_order" android:layout_alignRight="@+id/btn_order" android:layout_alignTop="@+id/btn_outlet" android:background="@drawable/feedback_button" /> <Button android:id="@+id/btn_games" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/btn_feedback" android:layout_alignLeft="@+id/btn_abtus" android:layout_alignRight="@+id/btn_abtus" android:layout_alignTop="@+id/btn_feedback" android:background="@drawable/games_button" /> <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="44dp" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:background="#98110e" > </RelativeLayout>

    Read the article

  • Part of my layout goes upward with keyboard

    - by Burak Dede
    My android app have a layout like this when i open keyboard two imageview at the bottom of the page shows up over the keyboard , i couldnt see the problem why it goes upward with the keyboard can you help me about this ? <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/searchLinear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/upperbackground"> <EditText android:id="@+id/searchBox" android:layout_alignParentTop="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:layout_margin="12dip" android:paddingLeft="35dip" android:textSize="15sp" android:background="@drawable/search_bar"/> </LinearLayout> <LinearLayout android:id="@+id/searchButtons" android:layout_below="@id/searchLinear" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal" android:background="@color/upperbackground"> <ImageView android:id="@+id/btnSukela" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:focusable="true" android:onClick="sukelaClickEvent" android:paddingRight="8dip" android:paddingBottom="5dip" android:src="@drawable/sukela"/> <ImageView android:id="@+id/btnSearch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/btnSukela" android:clickable="true" android:focusable="true" android:onClick="searchEntryClickEvent" android:paddingLeft="8dip" android:paddingBottom="5dip" android:src="@drawable/search"/> </LinearLayout> <RelativeLayout android:id="@+id/bottomLinear" android:layout_alignParentBottom="true" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal" android:background="@drawable/bottom_back"> <ImageView android:id="@+id/btnToday" android:src="@drawable/today" android:background="@color/bottombackground" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/bottomLinear" android:layout_marginBottom="19dip" android:layout_centerVertical="true" android:clickable="true" android:focusable="true" android:onClick="todayClickEvent"/> <ImageView android:id="@+id/btnPopular" android:src="@drawable/popular" android:background="@color/bottombackground" android:layout_toRightOf="@+id/btnToday" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:clickable="true" android:focusable="true" android:onClick="popularClickEvent"/> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/searchButtons" android:layout_above="@+id/bottomLinear" android:background="@color/background"> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </RelativeLayout> </RelativeLayout>

    Read the article

  • How can i fetch the large image from url

    - by Kutbi
    i used below code to fetch the image from url.but its not working for large image.. i missing something to add for that type of image to fetch. imgView = (ImageView)findViewById(R.id.ImageView01); imgView.setImageBitmap(loadBitmap("http://www.360technosoft.com/mx4.jpg")); //imgView.setImageBitmap(loadBitmap("http://sugardaddydiaries.com/wp-content/uploads/2010/12/how_do_i_get_sugar_daddy.jpg")); //setImageDrawable("http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg"); //Drawable drawable = LoadImageFromWebOperations("http://www.androidpeople.com/wp-content/uploads/2010/03/android.png"); //imgView.setImageDrawable(drawable); /* try { ImageView i = (ImageView)findViewById(R.id.ImageView01); Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg").getContent()); i.setImageBitmap(bitmap); } catch (MalformedURLException e) { System.out.println("hello"); } catch (IOException e) { System.out.println("hello"); }*/ } protected Drawable ImageOperations(Context context, String string, String string2) { // TODO Auto-generated method stub try { InputStream is = (InputStream) this.fetch(string); Drawable d = Drawable.createFromStream(is, "src"); return d; } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } }

    Read the article

  • How can I make a home widget behave like a launcher icon?

    - by Tughi
    I have a widget that acts as a launcher on the home screen. How can I make it behave like a launcher icon? I use this layout for portrait: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:background="@drawable/widget_background_selector" android:focusable="true" android:layout_width="74dip" android:layout_height="79dip" android:layout_marginLeft="3dip" android:layout_marginTop="14dip"> <ImageView android:id="@android:id/background" android:layout_width="72dip" android:layout_height="72dip" android:layout_marginLeft="1dip" android:layout_marginTop="4dip" /> </RelativeLayout> </RelativeLayout> And this is the background selector: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/widget_background_pressed" /> <item android:state_window_focused="true" android:state_focused="true" android:drawable="@drawable/widget_background_focused" /> <item android:state_window_focused="false" android:state_focused="true" android:drawable="@android:color/transparent" /> </selector> This way if I use the DPAD the widget is focusable but the click doesn't work. The touch still works but the widget is not displayed as focused. Any idea what I do wrong?

    Read the article

  • how do I set quad buffering with jogl 2.0

    - by tony danza
    I'm trying to create a 3d renderer for stereo vision with quad buffering with Processing/Java. The hardware I'm using is ready for this so that's not the problem. I had a stereo.jar library in jogl 1.0 working for Processing 1.5, but now I have to use Processing 2.0 and jogl 2.0 therefore I have to adapt the library. Some things are changed in the source code of Jogl and Processing and I'm having a hard time trying to figure out how to tell Processing I want to use quad buffering. Here's the previous code: public class Theatre extends PGraphicsOpenGL{ protected void allocate() { if (context == null) { // If OpenGL 2X or 4X smoothing is enabled, setup caps object for them GLCapabilities capabilities = new GLCapabilities(); // Starting in release 0158, OpenGL smoothing is always enabled if (!hints[DISABLE_OPENGL_2X_SMOOTH]) { capabilities.setSampleBuffers(true); capabilities.setNumSamples(2); } else if (hints[ENABLE_OPENGL_4X_SMOOTH]) { capabilities.setSampleBuffers(true); capabilities.setNumSamples(4); } capabilities.setStereo(true); // get a rendering surface and a context for this canvas GLDrawableFactory factory = GLDrawableFactory.getFactory(); drawable = factory.getGLDrawable(parent, capabilities, null); context = drawable.createContext(null); // need to get proper opengl context since will be needed below gl = context.getGL(); // Flag defaults to be reset on the next trip into beginDraw(). settingsInited = false; } else { // The following three lines are a fix for Bug #1176 // http://dev.processing.org/bugs/show_bug.cgi?id=1176 context.destroy(); context = drawable.createContext(null); gl = context.getGL(); reapplySettings(); } } } This was the renderer of the old library. In order to use it, I needed to do size(100, 100, "stereo.Theatre"). Now I'm trying to do the stereo directly in my Processing sketch. Here's what I'm trying: PGraphicsOpenGL pg = ((PGraphicsOpenGL)g); pgl = pg.beginPGL(); gl = pgl.gl; glu = pg.pgl.glu; gl2 = pgl.gl.getGL2(); GLProfile profile = GLProfile.get(GLProfile.GL2); GLCapabilities capabilities = new GLCapabilities(profile); capabilities.setSampleBuffers(true); capabilities.setNumSamples(4); capabilities.setStereo(true); GLDrawableFactory factory = GLDrawableFactory.getFactory(profile); If I go on, I should do something like this: drawable = factory.getGLDrawable(parent, capabilities, null); but drawable isn't a field anymore and I can't find a way to do it. How do I set quad buffering? If I try this: gl2.glDrawBuffer(GL.GL_BACK_RIGHT); it obviously doesn't work :/ Thanks.

    Read the article

  • Android ListView delete row button - focus issue

    - by Max Gontar
    Hi! I have an activity with ListView and buttons below: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ListView android:id="@+id/lvLamps" android:layout_width="fill_parent" android:layout_height="fill_parent" android:listSelector="@null" android:choiceMode="none" android:scrollbarStyle="insideInset" android:layout_weight="1.0" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight="0.0"> <Button android:id="@+id/btnAdd" android:background="@null" android:drawableLeft="@drawable/btn_upgrade" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableRight="@drawable/lbl_upgrade" android:textSize="0pt" android:text="" android:layout_alignParentLeft="true" android:padding="20px" /> <Button android:id="@+id/btnNext" android:background="@null" android:drawableRight="@drawable/next_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/lbl_next" android:textSize="0pt" android:text="" android:layout_alignParentRight="true" android:padding="20px" android:visibility="gone" /> <ImageButton android:id="@+id/btnListExit" android:background="@null" android:src="@drawable/btn_x" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:padding="20px" /> </RelativeLayout> </LinearLayout> ListView row contains delete button: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="true"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="true"> <ImageButton android:id="@+id/btnRowDelete" android:src="@drawable/btn_x" android:background="@null" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:padding="4px" android:focusable="true" android:focusableInTouchMode="true"/> <TextView android:id="@+id/txtLampRowFrom" android:text="123" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="6pt" android:layout_toRightOf="@id/btnRowDelete" android:focusable="false" android:textColor="@color/textColor"/> <TextView android:id="@+id/txtLampRowTo" android:text="123" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="6pt" android:layout_toRightOf="@id/btnRowDelete" android:layout_alignParentBottom="true" android:focusable="false" android:textColor="@color/textColor"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/arrow_upgrade_to" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:focusable="false"/> </RelativeLayout> </LinearLayout> In Adapter, Button onClickListener is set, also there are dummies to make list non-selectable: // disabling list items select public boolean areAllItemsEnabled() { return false; } public boolean isEnabled(int position) { return false; } What I want is: always show buttons in the bottom of screen after list (no matter how long it is, there should be scroll if it's too long) ListView should not be selectable, I don't want row selection row delete button should be selectable (focusable) with touch and with trackball And everything works except I can't focus row delete button with trackball (although it's working with touch). Can you help me? Thanks!

    Read the article

  • Android ListView delete row button - focus issue

    - by Max Gontar
    I have an activity with ListView and buttons below: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ListView android:id="@+id/lvLamps" android:layout_width="fill_parent" android:layout_height="fill_parent" android:listSelector="@null" android:choiceMode="none" android:scrollbarStyle="insideInset" android:layout_weight="1.0" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_weight="0.0"> <Button android:id="@+id/btnAdd" android:background="@null" android:drawableLeft="@drawable/btn_upgrade" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableRight="@drawable/lbl_upgrade" android:textSize="0pt" android:text="" android:layout_alignParentLeft="true" android:padding="20px" /> <Button android:id="@+id/btnNext" android:background="@null" android:drawableRight="@drawable/next_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/lbl_next" android:textSize="0pt" android:text="" android:layout_alignParentRight="true" android:padding="20px" android:visibility="gone" /> <ImageButton android:id="@+id/btnListExit" android:background="@null" android:src="@drawable/btn_x" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:padding="20px" /> </RelativeLayout> </LinearLayout> ListView row contains delete button: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="true"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="true"> <ImageButton android:id="@+id/btnRowDelete" android:src="@drawable/btn_x" android:background="@null" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:padding="4px" android:focusable="true" android:focusableInTouchMode="true"/> <TextView android:id="@+id/txtLampRowFrom" android:text="123" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="6pt" android:layout_toRightOf="@id/btnRowDelete" android:focusable="false" android:textColor="@color/textColor"/> <TextView android:id="@+id/txtLampRowTo" android:text="123" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="6pt" android:layout_toRightOf="@id/btnRowDelete" android:layout_alignParentBottom="true" android:focusable="false" android:textColor="@color/textColor"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/arrow_upgrade_to" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:focusable="false"/> </RelativeLayout> </LinearLayout> In Adapter, Button onClickListener is set, also there are dummies to make list non-selectable: // disabling list items select public boolean areAllItemsEnabled() { return false; } public boolean isEnabled(int position) { return false; } What I want is: always show buttons in the bottom of screen after list (no matter how long it is, there should be scroll if it's too long) ListView should not be selectable, I don't want row selection row delete button should be selectable (focusable) with touch and with trackball And everything works except I can't focus row delete button with trackball (although it's working with touch). Can you help me? Thanks!

    Read the article

  • Ho to stop scrolling in a Gallery Widget?

    - by Alexi
    I loaded some images into a gallery. Now I'm able to scroll but once started scrolling the scrolling won't stop. I would like the gallery to just scroll to the next image and then stop until the user does the scroll gesture again. this is my code import android.widget.ImageView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class GalleryExample extends Activity { private Gallery gallery; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); gallery = (Gallery) findViewById(R.id.examplegallery); gallery.setAdapter(new AddImgAdp(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(GalleryExample.this, "Position=" + position, Toast.LENGTH_SHORT).show(); } }); } public class AddImgAdp extends BaseAdapter { int GalItemBg; private Context cont; private Integer[] Imgid = { R.drawable.a_1, R.drawable.a_2, R.drawable.a_3, R.drawable.a_4, R.drawable.a_5, R.drawable.a_6, R.drawable.a_7 }; public AddImgAdp(Context c) { cont = c; TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme); GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0); typArray.recycle(); } public int getCount() { return Imgid.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imgView = new ImageView(cont); imgView.setImageResource(Imgid[position]); i.setScaleType(ImageView.ScaleType.FIT_CENTER); imgView.setBackgroundResource(GalItemBg); return imgView; } } } and the xmlLayout file <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <Gallery xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/examplegallery" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >