Search Results

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

Page 12/29 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Android add image to button

    - by Christiaan de Jong
    I want to add an image to a Button (no imagebutton, as the particular button can either contain text or an image; plus the imagebutton has the same problem), while still retaining the original android-style button. So adding android:background in the XML doesn't cut it, as that will remove the android default button with rounded corners etc. (android.R.drawable.btn_default) Is this in any way possible? I think one way is to make a 9patch image for the button pressed (one for up and one for down) and onTouch Action_DOWN make a layered background drawable and put that onto the button, and doing the same thing but with another 9patch for onTouch Action_UP, but I think that will decrease the performance of the application substantially, as that will require quite a lot of resource reading and layer merging for all the button clicks (and for my application, that will be quite a lot). Is what I state above correct?

    Read the article

  • Android Out of memory regarding png image

    - by turtleboy
    I have a jpg image in my app that shows correctly. In my listview i'd like to make the image more transparent so it is easier to see the text. I changed the image to a png format and altered it's opacity in GIMP. Now that the new image is in the app drawable folder. Im getting the following error. why? 09-28 09:24:07.560: I/global(20140): call socket shutdown, tmpsocket=Socket[address=/178.250.50.40,port=80,localPort=35172] 09-28 09:24:07.570: I/global(20140): call socket shutdown, tmpsocket=Socket[address=/212.169.27.217,port=84,localPort=55656] 09-28 09:24:07.690: D/dalvikvm(20140): GC_FOR_ALLOC freed 113K, 4% free 38592K/39907K, paused 32ms 09-28 09:24:07.690: I/dalvikvm-heap(20140): Forcing collection of SoftReferences for 28072816-byte allocation 09-28 09:24:07.740: D/dalvikvm(20140): GC_BEFORE_OOM freed 9K, 4% free 38582K/39907K, paused 43ms 09-28 09:24:07.740: E/dalvikvm-heap(20140): Out of memory on a 28072816-byte allocation. 09-28 09:24:07.740: I/dalvikvm(20140): "main" prio=5 tid=1 RUNNABLE 09-28 09:24:07.740: I/dalvikvm(20140): | group="main" sCount=0 dsCount=0 obj=0x40a57490 self=0x1b6e9a8 09-28 09:24:07.740: I/dalvikvm(20140): | sysTid=20140 nice=0 sched=0/0 cgrp=default handle=1074361640 09-28 09:24:07.740: I/dalvikvm(20140): | schedstat=( 2289118000 760844000 2121 ) utm=195 stm=33 core=1 09-28 09:24:07.740: I/dalvikvm(20140): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 09-28 09:24:07.740: I/dalvikvm(20140): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:486) 09-28 09:24:07.740: I/dalvikvm(20140): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773) 09-28 09:24:07.740: I/dalvikvm(20140): at android.content.res.Resources.loadDrawable(Resources.java:2042) 09-28 09:24:07.740: I/dalvikvm(20140): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.View.<init>(View.java:2812) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.ViewGroup.<init>(ViewGroup.java:410) 09-28 09:24:07.740: I/dalvikvm(20140): at android.widget.LinearLayout.<init>(LinearLayout.java:174) 09-28 09:24:07.740: I/dalvikvm(20140): at android.widget.LinearLayout.<init>(LinearLayout.java:170) 09-28 09:24:07.740: I/dalvikvm(20140): at java.lang.reflect.Constructor.constructNative(Native Method) 09-28 09:24:07.740: I/dalvikvm(20140): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.LayoutInflater.createView(LayoutInflater.java:586) 09-28 09:24:07.740: I/dalvikvm(20140): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 09-28 09:24:07.740: I/dalvikvm(20140): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 09-28 09:24:07.740: I/dalvikvm(20140): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:278) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.Activity.setContentView(Activity.java:1897) 09-28 09:24:07.740: I/dalvikvm(20140): at com.carefreegroup.ShowMoreDetails.onCreate(ShowMoreDetails.java:26) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.Activity.performCreate(Activity.java:4543) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2181) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2260) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.ActivityThread.access$600(ActivityThread.java:139) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277) 09-28 09:24:07.740: I/dalvikvm(20140): at android.os.Handler.dispatchMessage(Handler.java:99) 09-28 09:24:07.740: I/dalvikvm(20140): at android.os.Looper.loop(Looper.java:156) 09-28 09:24:07.740: I/dalvikvm(20140): at android.app.ActivityThread.main(ActivityThread.java:5045) 09-28 09:24:07.740: I/dalvikvm(20140): at java.lang.reflect.Method.invokeNative(Native Method) 09-28 09:24:07.740: I/dalvikvm(20140): at java.lang.reflect.Method.invoke(Method.java:511) 09-28 09:24:07.740: I/dalvikvm(20140): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 09-28 09:24:07.740: I/dalvikvm(20140): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 09-28 09:24:07.740: I/dalvikvm(20140): at dalvik.system.NativeStart.main(Native Method) 09-28 09:24:07.740: E/dalvikvm(20140): Out of memory: Heap Size=46115KB, Allocated=38582KB, Limit=65536KB 09-28 09:24:07.740: E/dalvikvm(20140): Extra info: Footprint=39907KB, Allowed Footprint=46115KB, Trimmed=892KB 09-28 09:24:07.740: E/Bitmap_JNI(20140): Create Bitmap Failed. 09-28 09:24:07.740: A/libc(20140): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1) 09-28 09:24:09.750: I/dalvikvm(20367): Turning on JNI app bug workarounds for target SDK version 10... 09-28 09:24:09.940: D/dalvikvm(20367): GC_CONCURRENT freed 864K, 21% free 3797K/4771K, paused 2ms+2ms thanks. [update] @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.showmoredetailslayout); actualCallTime = (TextView)findViewById(R.id.actualcalltime); doubleUp = (TextView)findViewById(R.id.doubleupcallid); needName = (TextView)findViewById(R.id.needname); needNameLabel = (TextView)findViewById(R.id.neednamelabel); getRotaDetails = (Button)findViewById(R.id.buttongetrotadetails); intent = this.getIntent(); String actualTimeIn = intent.getStringExtra("actTimeIn"); String actualTimeOut = intent.getStringExtra("actTimeOut"); String doubleUpValue = intent.getStringExtra("doubleUpValue"); String needNameWithCommas = intent.getStringExtra("needNameWithCommas"); callID = intent.getStringExtra("callID"); String[] needs = needNameWithCommas.split(","); actualCallTime.setText("This call was completed at " + actualTimeIn + " -" + actualTimeOut); if( ! doubleUpValue.equalsIgnoreCase("") || doubleUpValue.equalsIgnoreCase("]")){ doubleUp.setText("This call was not a double up "); }else{ doubleUp.setText("This call was a double up " + doubleUpValue); } needNameLabel.setText("Purpose of Call: "); for (int i = 0; i < needs.length; i++){ needName.append( needs[i] + "\n"); } getRotaDetails.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ShowMoreDetails.this, GetRotaDetails.class); intent.putExtra("callIDExtra", callID); startActivity(intent); } }); } }

    Read the article

  • Transparent Dialog Alignment

    - by feragusper
    I'm trying to get a custom dialog with a transparent background doing this way: this.getWindow().setBackgroundDrawableResource(R.drawable.transparent); (where "R.drawable.transparent" is a reference to the color "#00000000") The weird issue on this is that I can't align my dialog window. It's always aligned to the left, even if I implicit set the Gravity of the window using: this.getWindow().setGravity(Gravity.CENTER); And if I just comment the line which set the transparent background, the alignment works fine. Any help would be much appreciated! Thanks.

    Read the article

  • can we use layout in Customview ?

    - by UMMA
    friends, i have a custom view class public class Zoom extends View { private Drawable image; private int zoomControler=20; public Zoom(Context context) { super(context); image=context.getResources().getDrawable(R.drawable.icon); setFocusable(true); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); //TransparentPanel tp = new TransparentPanel(this.getContext()); //Button MyButton = new Button(this.getContext()); //MyButton.setText("Press me"); //tp.addView(MyButton); image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler); image.draw(canvas); } } can i use SetContentView(R.layout.mylayout) in this custom view to display that design? or how can i display button with image ondraw method as i have commented the code ? any help would be appreciated.

    Read the article

  • BitmapFactory.decodeResource returns null value

    - by krasnoff
    I am tring to load bitmaps from an internal resource in a View object (the source itself is in "drawable" files). the code is: import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.View; public class BannerView extends View { private Bitmap m_Banner = null; public BannerView(Context context, AttributeSet attributeSet) { super(context, attributeSet); m_Banner = BitmapFactory.decodeResource(getResources(), R.drawable.banner); } } Why m_Banner value is null? thank you in advance Kobi

    Read the article

  • How to generate R.java by a manual on Linux platform

    - by user305787
    I have a question. I am developing android applcation on Linux platform because i have to make a system.img with a application. When adding a drawable resource and building the project with mm command, i met a below error. "cannot find symbol R.drawable.icon_send_type" At above error, the icon_send_type is the added resource. This error occurred because the mm command did not generate R.java. So, i want to know how to generate R.java by a manual on Linux platform. Please help me.

    Read the article

  • Android change Tab image (not backgound)

    - by user1143989
    I am using a TabHost which has 3 tabs. Each tab has a image + text. spec = tabHost.newTabSpec("MyTasks") .setIndicator(Html.fromHtml("<b><H2>My Tasks</H2></b>"), getResources().getDrawable(R.drawable.task )) .setContent(intent); tabHost.addTab(spec); I want to change image when I select a tab. I used following code to change it ... TabWidget tw = getTabWidget(); View leftTabView = tw.getChildAt(0); leftTabView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab1_drawable)); tab1_drawable is a xml (selector and items for each state). THIS IS SETTING AND CHANGING BACKGROUND NOT THE IMAGE I SET. How can I change it?

    Read the article

  • Android Uncaught Exception

    - by Agrim Asthana
    09-30 02:32:31.474: D/ddm-heap(214): Got feature list request 09-30 02:32:31.634: D/AndroidRuntime(214): Shutting down VM 09-30 02:32:31.634: W/dalvikvm(214): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 09-30 02:32:31.634: E/AndroidRuntime(214): Uncaught handler: thread main exiting due to uncaught exception 09-30 02:32:31.654: E/AndroidRuntime(214): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mjcet.mjcet/com.mjcet.mjcet.MJCET}: java.lang.ClassNotFoundException: com.mjcet.mjcet.MJCET in loader dalvik.system.PathClassLoader@44e8c820 09-30 02:32:31.654: E/AndroidRuntime(214): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.os.Handler.dispatchMessage(Handler.java:99) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.os.Looper.loop(Looper.java:123) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.app.ActivityThread.main(ActivityThread.java:4363) 09-30 02:32:31.654: E/AndroidRuntime(214): at java.lang.reflect.Method.invokeNative(Native Method) 09-30 02:32:31.654: E/AndroidRuntime(214): at java.lang.reflect.Method.invoke(Method.java:521) 09-30 02:32:31.654: E/AndroidRuntime(214): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-30 02:32:31.654: E/AndroidRuntime(214): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 09-30 02:32:31.654: E/AndroidRuntime(214): at dalvik.system.NativeStart.main(Native Method) 09-30 02:32:31.654: E/AndroidRuntime(214): Caused by: java.lang.ClassNotFoundException: com.mjcet.mjcet.MJCET in loader dalvik.system.PathClassLoader@44e8c820 09-30 02:32:31.654: E/AndroidRuntime(214): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 09-30 02:32:31.654: E/AndroidRuntime(214): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 09-30 02:32:31.654: E/AndroidRuntime(214): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 09-30 02:32:31.654: E/AndroidRuntime(214): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409) 09-30 02:32:31.654: E/AndroidRuntime(214): ... 11 more 09-30 02:32:31.684: I/dalvikvm(214): threadid=7: reacting to signal 3 09-30 02:32:31.684: E/dalvikvm(214): Unable to open stack trace file '/data/anr/traces.txt': Permission denied the above is my debugging output for the below activities LOGINACTIVITY.java package com.agrim.mjcet; import com.agrim.mjcet.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; //import android.widget.TextView; import android.widget.Button; import android.widget.EditText; import android.view.View.OnClickListener; public class LoginActivity extends Activity { EditText txtUserName; EditText txtPassword; Button btnLogin; Button btnCancel; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setting default screen to login.xml setContentView(R.layout.main); txtUserName=(EditText)this.findViewById(R.id.txtUname); txtPassword=(EditText)this.findViewById(R.id.txtPwd); btnLogin=(Button)this.findViewById(R.id.btnLogin); btnLogin=(Button)this.findViewById(R.id.btnLogin); btnLogin.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Switching to Register screen if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())) { Intent myIntent = new Intent(getApplicationContext(),SampleActivity.class); startActivityForResult(myIntent, 0); } } } ); } } SAMPLE ACTIVITY.java package com.agrim.mjcet; import com.agrim.mjcet.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; public class SampleActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set View to register.xml setContentView(R.layout.lol); TextView HomeScreen = (TextView) findViewById(R.id.back); HomeScreen.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // Closing registration screen // Switching to Login Screen/closing register screen finish(); } }); } } and here are my 2 layouts MAIN.XML <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" android:stretchColumns="1"> <TableRow> <TextView android:text="@string/user_name" android:textColor="#347235" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_marginLeft="25dip" android:layout_height="wrap_content"> </TextView> <EditText android:text="" android:inputType="text" android:id="@+id/txtUname" android:layout_weight="0.75" android:layout_width="wrap_content" android:layout_marginRight="10dip" android:layout_marginBottom="5dip" android:background="#FFFFFF" android:layout_height="wrap_content"> </EditText> </TableRow> <TableRow> <TextView android:text="@string/password" android:textColor="#347235" android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="25dip"> </TextView> <EditText android:text="" android:inputType="textPassword" android:id="@+id/txtPwd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dip" android:layout_weight="1" android:background="#FFFFFF" android:gravity="center"> </EditText> </TableRow> <TableRow> <Button android:id="@+id/btnLogin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FFFFFF" android:layout_marginTop="25dip" android:layout_marginLeft="50dip" android:onClick="onClickMyButton" android:text="@string/login" /> <Button android:id="@+id/btnCancel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FFFFFF" android:layout_marginTop="25dip" android:layout_marginLeft="100dip" android:layout_marginRight="50dip" android:text="@string/cancel" /> </TableRow> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" > <ImageView android:layout_width="fill_parent" android:layout_height="match_parent" android:scaleType="centerInside" android:src="@drawable/logo_invert" android:contentDescription="@drawable/logo_invert"/> </FrameLayout> </TableLayout> and finally LOL.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:background="#000000" android:layout_height="fill_parent" > <ImageView android:layout_width="fill_parent" android:id="@+id/back" android:layout_height="match_parent" android:scaleType="centerInside" android:src="@drawable/lol" android:contentDescription="@drawable/lol"> </ImageView> <RelativeLayout android:layout_width="match_parent" android:layout_height="138dp" android:orientation="vertical" android:gravity="bottom" > <TextView android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="@string/coming_soon" android:textColor="#347235" /> </RelativeLayout> </FrameLayout> I get a force close upon initialization.. and yes this is my first android app :)

    Read the article

  • Get the current location of the Gps? Showing the default one

    - by Gagandeep
    Need help Urgent!!!!! Did changes with help but still unsuccessful... I have to request location updates, but I am unsuccessful in implementing that... i modified the code but need help so that i can see the current location. PLEASE look through my code and help please.. I am learning this and new to this concept and android.. any help would be appreciated here is my code: package com.GoogleMaps; 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 android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class MapsActivity extends MapActivity { /** Called when the activity is first created. */ private MapView mapView; private LocationManager lm; private LocationListener ll; private MapController mc; GeoPoint p = null; Drawable defaultMarker = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView)findViewById(R.id.mapview); //show zoom in/out buttons mapView.setBuiltInZoomControls(true); //Standard view of the map(map/sat) mapView.setSatellite(false); // get zoom tool mapView.setBuiltInZoomControls(true); //get controller of the map for zooming in/out mc = mapView.getController(); // Zoom Level mc.setZoom(18); lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); ll = new MyLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, ll); //Get the current location in start-up lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); ll = new MyLocationListener(); lm.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, ll); //Get the current location in start-up if (lm.getLastKnownLocation(LocationManager.GPS_PROVIDER) != null){ GeoPoint p = new GeoPoint( (int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()*1000000), (int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude()*1000000)); mc.animateTo(p); } MyLocationOverlay myLocationOverlay = new MyLocationOverlay(); List<Overlay> list = mapView.getOverlays(); list.add(myLocationOverlay); } protected class MyLocationOverlay extends com.google.android.maps.Overlay { @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { Paint paint = new Paint(); super.draw(canvas, mapView, shadow); GeoPoint p = null; // Converts lat/lng-Point to OUR coordinates on the screen. Point myScreenCoords = new Point(); mapView.getProjection().toPixels(p, myScreenCoords); paint.setStrokeWidth(1); paint.setARGB(255, 255, 255, 255); paint.setStyle(Paint.Style.STROKE); Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint); canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint); return true; } } private class MyLocationListener implements LocationListener{ public void onLocationChanged(Location argLocation) { // TODO Auto-generated method stub p = new GeoPoint((int)(argLocation.getLatitude()*1000000), (int)(argLocation.getLongitude()*1000000)); Toast.makeText(getBaseContext(), "New location latitude [" +argLocation.getLatitude() + "] longitude [" + argLocation.getLongitude()+"]", Toast.LENGTH_SHORT).show(); mc.animateTo(p); mapView.invalidate(); // call this so UI of map was updated } public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } protected boolean isRouteDisplayed() { return false; } } catlog: 11-29 17:40:42.699: D/dalvikvm(371): GC_FOR_MALLOC freed 6074 objects / 369952 bytes in 74ms 11-29 17:40:42.970: I/MapActivity(371): Handling network change notification:CONNECTED 11-29 17:40:42.980: E/MapActivity(371): Couldn't get connection factory client 11-29 17:40:43.190: D/AndroidRuntime(371): Shutting down VM 11-29 17:40:43.190: W/dalvikvm(371): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 11-29 17:40:43.280: E/AndroidRuntime(371): FATAL EXCEPTION: main 11-29 17:40:43.280: E/AndroidRuntime(371): java.lang.NullPointerException 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:71) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.PixelConverter.toPixels(PixelConverter.java:61) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.GoogleMaps.MapsActivity$MyLocationOverlay.draw(MapsActivity.java:106) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.google.android.maps.MapView.onDraw(MapView.java:494) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.View.draw(View.java:6740) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.View.draw(View.java:6743) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.widget.FrameLayout.draw(FrameLayout.java:352) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1640) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.drawChild(ViewGroup.java:1638) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.View.draw(View.java:6743) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.widget.FrameLayout.draw(FrameLayout.java:352) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewRoot.draw(ViewRoot.java:1407) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewRoot.performTraversals(ViewRoot.java:1163) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.os.Handler.dispatchMessage(Handler.java:99) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.os.Looper.loop(Looper.java:123) 11-29 17:40:43.280: E/AndroidRuntime(371): at android.app.ActivityThread.main(ActivityThread.java:4627) 11-29 17:40:43.280: E/AndroidRuntime(371): at java.lang.reflect.Method.invokeNative(Native Method) 11-29 17:40:43.280: E/AndroidRuntime(371): at java.lang.reflect.Method.invoke(Method.java:521) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 11-29 17:40:43.280: E/AndroidRuntime(371): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 11-29 17:40:43.280: E/AndroidRuntime(371): at dalvik.system.NativeStart.main(Native Method) 11-29 17:40:45.779: D/dalvikvm(371): GC_FOR_MALLOC freed 5970 objects / 506624 bytes in 1179ms 11-29 17:40:45.779: I/dalvikvm-heap(371): Grow heap (frag case) to 3.147MB for 17858-byte allocation 11-29 17:40:45.870: D/dalvikvm(371): GC_FOR_MALLOC freed 56 objects / 2304 bytes in 92ms 11-29 17:40:45.960: D/dalvikvm(371): GC_EXPLICIT freed 3459 objects / 196432 bytes in 74ms 11-29 17:40:48.310: D/dalvikvm(371): GC_EXPLICIT freed 116 objects / 41448 bytes in 68ms 11-29 17:40:49.540: I/Process(371): Sending signal. PID: 371 SIG: 9

    Read the article

  • How to open new view (call an activity) from options menu defined in XML? (android)

    - by Portablejim
    I cant seem to open a new view from an options menu item. The program keeps crashing as it applies the intent and listener to the item. I am just beginning, so please be nice. The current view is mnfsms, and the view I am trying to open is mnfsms_settings. I am developing for 1.5. Could someone please help me get the menu working. The menu (called options_menu.xml): <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/settings_button" android:title="Settings" android:icon="@android:drawable/ic_menu_preferences" /> <item android:id="@+id/about_button" android:title="About" android:icon="@android:drawable/ic_menu_myplaces" /> </menu> The main view (called mnfsms.java): package com.example.mnfsms; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; public class mnfsms extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* OnClickListener myocl = new View.OnClickListener() { public void onClick(View v){ Intent myi = new Intent(mnfsms.this, mnfsms_settings.class); startActivity(myi); } };*/ } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); MenuItem mi_settings = (MenuItem)findViewById(R.id.settings_button); mi_settings.setIntent(new Intent(this, mnfsms_settings.class)); return true; } } The manifest: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mnfsms" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".mnfsms" android:label="@string/main_window_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".mnfsms_settings" android:label="string/main_window_name"> </activity> </application> <uses-sdk android:minSdkVersion="3" /> </manifest> The stacktrace: 01-06 15:07:58.045: ERROR/AndroidRuntime(2123): Uncaught handler: thread main exiting due to uncaught exception 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): java.lang.NullPointerException 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.example.mnfsms.mnfsms.onCreateOptionsMenu(mnfsms.java:30) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.app.Activity.onCreatePanelMenu(Activity.java:2038) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:421) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:664) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1278) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1735) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2188) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2158) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.view.ViewRoot.handleMessage(ViewRoot.java:1490) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.os.Handler.dispatchMessage(Handler.java:99) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.os.Looper.loop(Looper.java:123) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at android.app.ActivityThread.main(ActivityThread.java:3948) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at java.lang.reflect.Method.invokeNative(Native Method) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at java.lang.reflect.Method.invoke(Method.java:521) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 01-06 15:07:58.055: ERROR/AndroidRuntime(2123): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • java.lang.RuntimeException: Unable to start activity ComponentInfo cannot be cast to android.widget.ZoomControls

    - by Hwl
    I'm new to android development, hope you all can help me. I got this androidVNC viewer source code from internet. When i'm running the androidVNC application in the emulator, it will exit automatically then i get following errors in LogCat. Can anyone one help me? Thanks. FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{android.androidVNC/android.androidVNC.VncCanvasActivity}: java.lang.ClassCastException: com.antlersoft.android.zoomer.ZoomControls cannot be cast to android.widget.ZoomControls at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980) at android.app.ActivityThread.access$600(ActivityThread.java:122) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4340) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassCastException: com.antlersoft.android.zoomer.ZoomControls cannot be cast to android.widget.ZoomControls at android.androidVNC.VncCanvasActivity.onCreate(VncCanvasActivity.java:585) at android.app.Activity.performCreate(Activity.java:4465) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919) ... 11 more This is the ZoomControls java file: package com.antlersoft.android.zoomer; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.animation.AlphaAnimation; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.ZoomButton; public class ZoomControls extends LinearLayout { private final ZoomButton mZoomIn; private final ZoomButton mZoomOut; private final ImageButton mZoomKeyboard; public ZoomControls(Context context) { this(context, null); } public ZoomControls(Context context, AttributeSet attrs) { super(context, attrs); setFocusable(false); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.zoom_controls, this, // we are the parent true); mZoomIn = (ZoomButton) findViewById(R.id.zoomIn); mZoomOut = (ZoomButton) findViewById(R.id.zoomOut); mZoomKeyboard = (ImageButton) findViewById(R.id.zoomKeys); } public void setOnZoomInClickListener(OnClickListener listener) { mZoomIn.setOnClickListener(listener); } public void setOnZoomOutClickListener(OnClickListener listener) { mZoomOut.setOnClickListener(listener); } public void setOnZoomKeyboardClickListener(OnClickListener listener) { mZoomKeyboard.setOnClickListener(listener); } /* * Sets how fast you get zoom events when the user holds down the * zoom in/out buttons. */ public void setZoomSpeed(long speed) { mZoomIn.setZoomSpeed(speed); mZoomOut.setZoomSpeed(speed); } @Override public boolean onTouchEvent(MotionEvent event) { /* Consume all touch events so they don't get dispatched to the view * beneath this view. */ return true; } public void show() { fade(View.VISIBLE, 0.0f, 1.0f); } public void hide() { fade(View.GONE, 1.0f, 0.0f); } private void fade(int visibility, float startAlpha, float endAlpha) { AlphaAnimation anim = new AlphaAnimation(startAlpha, endAlpha); anim.setDuration(500); startAnimation(anim); setVisibility(visibility); } public void setIsZoomInEnabled(boolean isEnabled) { mZoomIn.setEnabled(isEnabled); } public void setIsZoomOutEnabled(boolean isEnabled) { mZoomOut.setEnabled(isEnabled); } @Override public boolean hasFocus() { return mZoomIn.hasFocus() || mZoomOut.hasFocus(); } } This is the zoom_controls XML file: <merge xmlns:android="http://schemas.android.com/apk/res/android"> <ZoomButton android:id="@+id/zoomOut" android:background="@drawable/btn_zoom_down" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageButton android:id="@+id/zoomKeys" android:background="@android:drawable/ic_dialog_dialer" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ZoomButton android:id="@+id/zoomIn" android:background="@drawable/btn_zoom_up" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </merge>

    Read the article

  • Android project problem

    - by qwerty
    Hello, here I uploaded my Android project made in Eclipse. The idea is that i have a service, which computes the sum of two random numbers. But when i press the OK Button, i don't see the result in that edit box... why? What i'm doing wrong? Please help Thanks! EDIT: The code: //service class package service; import java.util.Random; import com.android.AplicatieSuma; import android.widget.EditText; import android.widget.TextView; public class ServiciuSuma { public ServiciuSuma() { } public int CalculateSum() { Random generator=new Random(); int n=generator.nextInt(); int m=generator.nextInt(); return n+m; } } The Application class: package com.android; import android.app.*; import service.*; public class ApplicationSum extends Application { public ServiciuSuma service = new ServiciuSuma(); } and the main Activity class: package com.android; import com.android.R; import android.app.Activity; import android.content.Intent; import android.graphics.Color; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.graphics.PorterDuff; import android.os.Bundle; import android.provider.Settings; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; public class Activitate extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View btn_ok = findViewById(R.id.btn_ok); btn_ok.setOnClickListener(new OnClickListener() { public void onClick(View v) { CalculeazaSuma(); } }); } private void CalculeazaSuma() { AplicatieSuma appState = ((AplicatieSuma)this.getApplication()); EditText txt_amount = (EditText)findViewById(R.id.txt_amount); txt_amount.setText(appState.service.CalculateSum()); //BindData(); } } So that edit text does not show the sum of the random generated numbers, by the service. What's wrong? Thanks EDIT: the manifest xml file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android" android:versionCode="1" android:versionName="1.0.1"> <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" /> <application android:name="ApplicationSum" android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:label="@string/app_name" android:name=".Activitate"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" /> </manifest>

    Read the article

  • RelativeLayout, ScrollView and navigation bar at bottom

    - by MicNeo
    What I want to do is, make layout like this: Title Date Long text with scrolling Navigation bar stick to the bottom Well I have done everything, however there is a little problem with scrolling. I want only to scroll text. Title and date should be stick to the top, and nav bar to the bottom of activity. And yes, it works, but my nav bar overlaps text :/ I tried everything, there is one solution I found, set fixed height for Scrollview, but this will not work on every devices well, isn't it? I probably could do some calculation in code, and on it change height, but I would like to stay in XML. Any one have any suggestions? Here is my XML file: <?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" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.6" android:orientation="vertical" > <TextView android:id="@+id/feed_title" style="@style/h1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" /> <TextView android:id="@+id/feed_info" style="@style/h2" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> <ImageView android:id="@+id/feed_fav_ico" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentRight="true" android:layout_gravity="center_vertical|right" android:background="@drawable/ic_fav_off" /> </LinearLayout> <ScrollView android:layout_width="fill_parent" android:layout_height="match_parent" android:fillViewport="true" android:scrollY="20dp" > <TextView android:id="@+id/feed_text" style="@style/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Loren ipsum full tekst" /> </ScrollView> </LinearLayout> <!-- Buttons --> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="#FFFFFF" android:orientation="vertical" android:paddingBottom="5dp" > <Button android:id="@+id/go_to_article" style="@style/button_screen" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" android:layout_marginTop="15dp" android:text="@string/feed_show_full" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > <Button android:id="@+id/next_feed" style="@style/button_screen" android:layout_width="40dp" android:layout_height="40dp" android:background="@drawable/button_arrow_up" /> <Button android:id="@+id/share_feed" style="@style/button_screen" android:layout_width="100dp" android:layout_height="40dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:text="@string/feed_share" /> <Button android:id="@+id/delete_feed" style="@style/button_screen" android:layout_width="100dp" android:layout_height="40dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:text="@string/feed_delete" /> <Button android:id="@+id/prev_feed" android:layout_width="40dp" android:layout_height="40dp" android:background="@drawable/button_arrow_down" /> </LinearLayout> </LinearLayout> <!-- ~Buttons --> </RelativeLayout>

    Read the article

  • How to set icon to title bar for each Activity in Tablelayout in android

    - by Venu Gopal
    In my tablayout example, i have created 3 tabs, as usually i set 3 activities for each tab. I can set image to title bar of activity, which adds the intent to each tab. Due to this, the image in the title bar is visible in all 3 tabs. My requirement is to set a different image to title bar for each activity. I followed this to set image to title bar. But when i am going to do the same thing to each activity, getting android.util.AndroidRuntimeException: You cannot combine custom titles with other title features this error and application is terminated. manifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aptitsolution.tablayout" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/MyTheme"> <activity android:name=".TabLayoutDemo" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="AlbumsActivity"></activity> <activity android:name="ArtistsActivity"></activity> <activity android:name="SongsActivity"></activity> TabLayoutDemo.java public class TabLayoutDemo extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) intent = new Intent().setClass(this, ArtistsActivity.class); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("artists").setIndicator("Artists", res.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(spec); .... .... ArtistsActivity.java public class ArtistsActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);//here i am getting the error setContentView(R.layout.artists); setFeatureDrawableResource(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title); } } my_title.xml <?xml version="1.0" encoding="utf-8"?><RelativeLayout android:id="@+id/header" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent"> <ImageView android:id="@+id/titleImage" android:src="@drawable/nowplaying" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/titleText" android:layout_toRightOf="id/titleImage"android:layout_width="wrap_content" android:text="New Title" android:layout_height="wrap_content"/> thanks venu

    Read the article

  • java.lang.OutOfMemoryError: bitmap size exceeds VM budget

    - by Angel
    Hi, I am trying to change the layout of my application from portrait to landscape and vice-versa. But if i do it frequently or more than once then at times my application crashes.. Below is the error log. Please suggest what can be done? < 01-06 09:52:27.787: ERROR/dalvikvm-heap(17473): 1550532-byte external allocation too large for this process. 01-06 09:52:27.787: ERROR/dalvikvm(17473): Out of memory: Heap Size=6471KB, Allocated=4075KB, Bitmap Size=9564KB 01-06 09:52:27.787: ERROR/(17473): VM won't let us allocate 1550532 bytes 01-06 09:52:27.798: DEBUG/skia(17473): --- decoder-decode returned false 01-06 09:52:27.798: DEBUG/AndroidRuntime(17473): Shutting down VM 01-06 09:52:27.798: WARN/dalvikvm(17473): threadid=3: thread exiting with uncaught exception (group=0x4001e390) 01-06 09:52:27.807: ERROR/AndroidRuntime(17473): Uncaught handler: thread main exiting due to uncaught exception 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): java.lang.RuntimeException: Unable to start activity ComponentInfo{}: android.view.InflateException: Binary XML file line #2: Error inflating class 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3812) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.ActivityThread.access$2300(ActivityThread.java:126) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1936) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.os.Handler.dispatchMessage(Handler.java:99) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.os.Looper.loop(Looper.java:123) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.ActivityThread.main(ActivityThread.java:4595) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at java.lang.reflect.Method.invokeNative(Native Method) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at java.lang.reflect.Method.invoke(Method.java:521) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at dalvik.system.NativeStart.main(Native Method) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.LayoutInflater.createView(LayoutInflater.java:513) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.LayoutInflater.inflate(LayoutInflater.java:385) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.Activity.setContentView(Activity.java:1629) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at onCreate(Game.java:98) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): ... 12 more 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): Caused by: java.lang.reflect.InvocationTargetException 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.widget.LinearLayout.(LinearLayout.java:92) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at java.lang.reflect.Constructor.constructNative(Native Method) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.LayoutInflater.createView(LayoutInflater.java:500) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): ... 22 more 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:464) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:340) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.content.res.Resources.loadDrawable(Resources.java:1705) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.content.res.TypedArray.getDrawable(TypedArray.java:548) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.View.(View.java:1850) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.View.(View.java:1799) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): at android.view.ViewGroup.(ViewGroup.java:296) 01-06 09:52:27.857: ERROR/AndroidRuntime(17473): ... 26 more

    Read the article

  • Android refresh StateListDrawable problem

    - by Max
    Hi all, I have a strange problem with StateListDrawable or maybe (probably) I'm missing something. I created a test application for it and the same problem occurs. So, this is my StateListDrawable resourse in file test_selection.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true"> <shape android:shape="rectangle" android:background="#ff0000"> <corners android:radius="10dp" /> <gradient android:startColor="#ff5555" android:endColor="#ff5555" android:angle="0" /> </shape> </item> <item android:state_selected="false"> <shape android:shape="rectangle" android:background="#eeeeee"> <corners android:radius="10dp" /> <gradient android:startColor="#eeeeee" android:endColor="#eeeeee" android:angle="0" /> </shape> </item> </selector> It's a very simple selector that draw a red color for selected state and a white rect for the unselected one. My main.xml template is very simple. I simply use a TextView that uses the selection as background. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:textSize="30dp" android:id="@+id/test_view_example" android:background="@drawable/test_selection"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/refresh" android:onClick="updateView" android:text="refresh"></Button> </LinearLayout> My Activity code is also very simple. public class TestDrawableStateActivity extends Activity { private final static int[] SELECTED_STATE = { android.R.attr.state_selected }; private final static int[] UNSELECTED_STATE = {}; private TextView textView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); textView = (TextView) findViewById(R.id.test_view_example); } @Override protected void onResume() { super.onResume(); // Carichiamo la Drawable if(textView.getBackground().setState(SELECTED_STATE)){ textView.invalidate(); } } public void updateView(View view) { if(textView.getBackground().setState(SELECTED_STATE)){ textView.invalidate(); }; } } When Activity starts I try to set the state of my Drawable (the StateListDrawable) with the value SELECTED. It seems all very simple.... but the problem is that the state is not shown. If, later, I click a button and execute the method updateView() the state changes. Where is my problem? Where am I wrong? Thankx a lot Max

    Read the article

  • Accessing Layout Items from inside Widget AppWidgetProvider

    - by cam4mav
    I am starting to go insane trying to figure this out. It seems like it should be very easy, I'm starting to wonder if it's possible. What I am trying to do is create a home screen widget, that only contains an ImageButton. When it is pressed, the idea is to change some setting (like the wi-fi toggle) and then change the Buttons image. I have the ImageButton declared like this in my main.xml <ImageButton android:id="@+id/buttonOne" android:src="@drawable/button_normal_ringer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> my AppWidgetProvider class, named ButtonWidget * note that the RemoteViews class is a locally stored variable. this allowed me to get access to the RViews layout elements... or so I thought. @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { remoteViews = new RemoteViews(context.getPackageName(), R.layout.main); Intent active = new Intent(context, ButtonWidget.class); active.setAction(VIBRATE_UPDATE); active.putExtra("msg","TESTING"); PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); remoteViews.setOnClickPendingIntent(R.id.buttonOne, actionPendingIntent); appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); } @Override public void onReceive(Context context, Intent intent) { // v1.5 fix that doesn't call onDelete Action final String action = intent.getAction(); Log.d("onReceive",action); if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { final int appWidgetId = intent.getExtras().getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) { this.onDeleted(context, new int[] { appWidgetId }); } } else { // check, if our Action was called if (intent.getAction().equals(VIBRATE_UPDATE)) { String msg = "null"; try { msg = intent.getStringExtra("msg"); } catch (NullPointerException e) { Log.e("Error", "msg = null"); } Log.d("onReceive",msg); if(remoteViews != null){ Log.d("onReceive",""+remoteViews.getLayoutId()); remoteViews.setImageViewResource(R.id.buttonOne, R.drawable.button_pressed_ringer); Log.d("onReceive", "tried to switch"); } else{ Log.d("F!", "--naughty language used here!!!--"); } } super.onReceive(context, intent); } } so, I've been testing this and the onReceive method works great, I'm able to send notifications and all sorts of stuff (removed from code for ease of reading) the one thing I can't do is change any properties of the view elements. To try and fix this, I made RemoteViews a local and static private variable. Using log's I was able to see that When multiple instances of the app are on screen, they all refer to the one instance of RemoteViews. perfect for what I'm trying to do The trouble is in trying to change the image of the ImageButton. I can do this from within the onUpdate method using this. remoteViews.setImageViewResource(R.id.buttonOne, R.drawable.button_pressed_ringer); that doesn't do me any good though once the widget is created. For some reason, even though its inside the same class, being inside the onReceive method makes that line not work. That line used to throw a Null pointer as a matter of fact, until I changed the variable to static. now it passes the null test, refers to the same layoutId as it did at the start, reads the line, but it does nothing. Its like the code isn't even there, just keeps chugging along. SO...... Is there any way to modify layout elements from within a widget after the widget has been created!? I want to do this based on the environment, not with a configuration activity launch. I've been looking at various questions and this seems to be an issue that really hasn't been solved, such as link text and link text oh and for anyone who finds this and wants a good starting tutorial for widgets, this is easy to follow (though a bit old, it gets you comfortable with widgets) .pdf link text hopefully someone can help here. I kinda have the feeling that this is illegal and there is a different way to go about this. I would LOVE to be told another approach!!!! Thanks

    Read the article

  • Application using JOGL stays in Limbo when closing

    - by Roy T.
    I'm writing a game using Java and OpenGL using the JOGL bindings. I noticed that my game doesn't terminate properly when closing the window even though I've set the closing operation of the JFrame to EXIT_ON_CLOSE. I couldn't track down where the problem was so I've made a small reproduction case. Note that on some computers the program terminates normally when closing the window but on other computers (notably my own) something in the JVM keeps lingering, this causes the JFrame to never be disposed and the application to never exit. I haven't found something in common between the computers that had difficulty terminating. All computers had Windows 7, Java 7 and the same version of JOGL and some terminated normally while others had this problem. The test case is as follows: public class App extends JFrame implements GLEventListener { private GLCanvas canvas; @Override public void display(GLAutoDrawable drawable) { GL3 gl = drawable.getGL().getGL3(); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL3.GL_COLOR_BUFFER_BIT); gl.glFlush(); } // The overrides for dispose (the OpenGL one), init and reshape are empty public App(String title, boolean full_screen, int width, int height) { //snipped setting the width and height of the JFRAME GLProfile profile = GLProfile.get(GLProfile.GL3); GLCapabilities capabilities = new GLCapabilities(profile); canvas = new GLCanvas(capabilities); canvas.addGLEventListener(this); canvas.setSize(getWidth(), getHeight()); add(canvas); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //!!! setVisible(true); } @Override public void dispose() { System.out.println("HELP"); // } public static void main( String[] args ) { new App("gltut 01", false, 1280, 720); } } As you can see this doesn't do much more than adding a GLCanvas to the frame and registering the main class as the GLEventListener. So what keeps lingering? I'm not sure. I've made some screenshots. The application running normally. The application after the JFrame is closed, note that the JVM still hasn't exited or printed a return code. The application after it was force closed. Note the return code -1, so it wasnt just the JVM standing by or something the application really hadn't exited yet. So what is keeping the application in Limbo? Might it be the circular reference between the GLCanvas and the JFrame? I thought the GC could figure that out. If so how should I deal with that when I want to exit? Is there any other clean-up required when using JOGL? I've tried searching but it doesn't seem to be necessary. Edit, to clarify: there are 2 dispose functions dispose(GLAutoDrawable arg) which is a member of GLEventListener and dispose() which is a member of JFrame. The first one is called correctly (but I wouldn't know what to there, destroying the GLAutoDrawable or the GLCanvas gives an infinite exception loop) the second one is never called.

    Read the article

  • Problem with Android Layout

    - by Ryan
    I'm having a very hard time getting the 2 buttons in the 2nd child linearlayout to display as I want them to... I want them centered on screen but they appear left-aligned. Can anyone help me with this? <?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:background="@color/black" android:orientation="vertical"> <LinearLayout android:id="@+id/splash" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/imageLogo1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:cropToPadding="true" android:scaleType="fitXY" android:src="@drawable/isi_logo" android:paddingLeft="50sp" android:paddingRight="50sp" android:paddingTop="20sp"/> <ImageView android:id="@+id/imageLogo2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:cropToPadding="true" android:scaleType="fitXY" android:src="@drawable/sa_logo" android:paddingLeft="100sp" android:paddingRight="100sp" android:paddingBottom="20sp"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center"> <Button android:id="@+id/buttonScores" android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="100sp" android:text="@string/scores"/> <Button android:id="@+id/buttonStart" android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="100sp" android:text="@string/test"/> </LinearLayout> </LinearLayout>

    Read the article

  • How to change theme for AlertDialog.

    - by Min Soo Kim
    Hello everyone, I was wondering if someone could help me out. I am trying to create a custom AlertDialog. In order to do this, I added the following line of code in styles.xml @drawable/color_panel_background color_panel_background.9.png is located in drawable folder. This is also available in Android SDK res folder. The following is the main activity. package com.customdialog; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; public class CustomDialog extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); this.setTheme(R.style.CustomAlertDialog); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("HELLO!"); builder .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //MyActivity.this.finish(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //dialog.cancel(); } }); AlertDialog alertdialog = builder.create(); alertdialog.show(); } } In order to apply the theme to an AlertDialog, I had to set the theme to the current context. However, I just can't seem to get the app to show customized AlertDialog. Can anyone help me out with this, and thank you very much in advance!

    Read the article

  • android: start an intent into a framelayout

    - by user329692
    Hi guys! I have a main activity with this layout file: <?xml version="1.0" encoding="utf-8"?> <Button android:id="@+id/btn_reload" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Reload" /> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical|center_horizontal" > <ImageView android:id="@+id/ImageView01" android:src="@drawable/logo_head" android:scaleType="fitStart" android:adjustViewBounds="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout> <FrameLayout android:id="@+id/center" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"> </FrameLayout> <LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="center" android:id="@+id/footer" android:layout_weight="2.6" android:background="#ffffff"> </LinearLayout> Basically it is composed by an header, a central part (android:id="@+id/center") and a footer. The footer contains four buttons, created dinamically. At the end it looks like a TabWidget with the tabs at the botton. Each footer's buttons holds an Intent/activity. The question is: How can i start my activity into the FrameLayout? For instance TabHost does this: ..... spec = tabHost .newTabSpec(tabTitle.toLowerCase()) .setIndicator(tabTitle,res.getDrawable(R.drawable.tab_spec)) .setContent(intent); tabHost.addTab(spec); ....

    Read the article

  • Is there a detailed description of optimizations in the Android build process?

    - by Daniel Lew
    I've been curious as to all the optimizations that go into the building of an .apk. I'm curious because of two things I've tried in the past to bring down the size of my .apk: I have had a few large json assets in projects before, as well as a static sqlite database. I tried bringing down the size of the apk by gzipping them before the build process, but the resulting size is exactly the same. I just today tried pngcrush on my /drawable/ folders. The resulting build was exactly the same size as before. I would think that perhaps #1 could be explained by the zip process, but simply zipping the /drawable/ folders in #2 result in different-sized files. Perhaps the build process runs something akin to pngcrush? Regardless, I was wondering if anyone knew where to find a detailed description of all the optimizations in the Android build process. I don't want to waste my time trying to optimize what is already automated, and also I think it'd help my understanding of the resulting apk. Does anyone know if this is documented anywhere?

    Read the article

  • Custom title with image

    - by Alex Volovoy
    Hi all, i'm creating custom title for activity by disabling standard one and managing everything myself. I wonder if it's possible to replace/theme standart title to my needs. I can customize size, background image, and text via themes by changing windowXYZStyle items. The only thing i couldn't find - how i can add image instead of text. I've tried requestWindowFeature(Window.FEATURE_CUSTOM_TITLE) and assign custom layout - but it doesn't seems to work. EDIT : Here is a report of testing suggestions, code is below - result - image view is not showing up. Activity public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); } } XML : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/title" android:layout_width="fill_parent" android:layout_height="26dip" android:paddingLeft="5dip" android:background="@drawable/titlebar_bg" android:layout_gravity="left|center" > <ImageView android:id="@+id/logo" android:src="@drawable/title_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

    Read the article

  • imageview weights in linearlayout

    - by Metalex
    I have this layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" android:minWidth="100dp" > <TextView android:id="@+id/txt_what_way" android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="4" android:textAppearance="?android:attr/textAppearanceMedium" /> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="3"> <ImageView android:layout_width="20dp" android:layout_height="20dp" android:scaleType="fitCenter" android:src="@drawable/ic_launcher"/> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="3"> <ImageView android:layout_width="20dp" android:layout_height="20dp" android:scaleType="fitCenter" android:src="@drawable/ic_launcher"/> </LinearLayout> </LinearLayout> I want that it looks like: TextView - 40% of width, Layout with ImageView - 30% of widht, Layout with ImageView - 30% of width. But the output is: TextViewImageViewImageView----------------free space---------------------------------- Thanks for your help! -- EDITED Done it in programmatic way

    Read the article

  • WebView inside Tab hiding the tabWidgets

    - by brockoli
    I'm having trouble with a WebView always filling the full screen and thus covering my tabs. Here is my code for the tabhost.. public class tabNZBMobile extends TabActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Reusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) intent = new Intent().setClass(this, NewzbinMobile.class); // Initialize a TabSpec for each tab and add it to the TabHost spec = tabHost.newTabSpec("search").setIndicator("Search", res.getDrawable(R.drawable.ic_tab_search)) .setContent(intent); tabHost.addTab(spec); // Do the same for the other tabs intent = new Intent().setClass(this, sabnzbWeb.class); spec = tabHost.newTabSpec("sabnzbweb").setIndicator("SabNZBd", res.getDrawable(R.drawable.ic_tab_sabnzbweb)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTabByTag("search"); }} My first tab (NewzbinMobile.class) displays correctly, it's just a relativelayout. But my second tab is an activity showing a webview and it is showing, but using the whole screen, covering my tabs. Here is the code for my second tab. public class sabnzbWeb extends Activity { WebView mWebView; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String sabNZBurl = new String("http://test.server.org:8080/m"); mWebView = new WebView(this); mWebView.getSettings().setJavaScriptEnabled(true); setContentView(mWebView); mWebView.loadUrl(sabNZBurl); }}

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >