Search Results

Search found 12035 results on 482 pages for 'android emulator'.

Page 21/482 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • android: AbsListView.OnScrollListener SCROLL_STATE_IDLE is not called after SCROLL_STATE_TOUCH_SCROL

    - by Francesco
    I have a problem with android version 2.1. It looks like a bug. I attached an OnScrollListener to my listView. I'm using the method onScrollStateChanged(AbsListView view, int scrollState) for monitoring the scroll's state of my listview. The scrollstate could assume 3 value (taken from the documentation): SCROLL_STATE_FLING: The user had previously been scrolling using touch and had performed a fling. The animation is now coasting to a stop SCROLL_STATE_IDLE:The view is not scrolling. Note navigating the list using the trackball counts as being in the idle state since these transitions are not animated. SCROLL_STATE_TOUCH_SCROLL:The user is scrolling using touch, and their finger is still on the screen I assume that the SCROLL_STATE_IDLE will always be passed after one of other two states. It's always true excepted for android version 2.1. SCROLL_STATE_IDLE is not passed after SCROLL_STATE_TOUCH_SCROLL The problem happens also if you stop the fling by a touch instead of let the scroll stop by itself. This strange behaviour leaves my listView in an unconsistate state. Someonelse has the same problem? Suggestion for a "not-so-dirty" work around?

    Read the article

  • how does scrolling in android listview work?

    - by gartenkralleb
    hi, i have an android-app with a listview in an activity. the listview has, if i call it so, three data states. no data loaded from inet - only one dummy item is visible, saying that data is loading data is loaded and shown in list one listitem is clicked and now shows more information for this listitem (so it is increased in its height) on every state change (1 - 2, 2 - 3) i call notifyDataSetChanged() on this ListAdapater. this causes the listview to scroll down to the last item. this is ugly in the first transition and even more ugly in the second because the clicked list item is now out of focus. as i can see, this happens with a google g1 with android 1.6. a htc touch with the same sdk acts like desired (i try to figure it out with some more devices). to avoid this i tried to read out getScrollY() and set this value back. but this returns 0. the reason for this return value i already found on stackoverflow in other qutestions. does anyone else comes along with my problem so far? why does the listview scrolls to the last item? it was mentioned, that listview does keep track on the scroll position. but it seems that it does not in my case. or may i call the wrong refresh method? is notifyDataSetChanged the correct one?

    Read the article

  • Android - Views in Custom Compound Component are not inflated (findByView returns null)

    - by Julian Arz
    I have made a Custom Component in XML, consisting of a button with an imageview stacked on top of it: <myapp.widget.ClearableCaptionedButton xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/ccbutton_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical|left" android:textAppearance="?android:attr/textAppearanceMedium" android:background="@android:drawable/edit_text"/> <ImageView android:id="@+id/ccbutton_clear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="5dip" android:layout_alignRight="@id/ccbutton_button" android:layout_alignTop="@id/ccbutton_button" android:layout_alignBottom="@id/ccbutton_button"/> </myapp.widget.ClearableCaptionedButton> extract of java source code: public class ClearableCaptionedButton extends RelativeLayout implements OnClickListener { ... public ClearableCaptionedButton(Context context, AttributeSet attrs) { super(context, attrs); // some stuff that works fine } .. protected void onFinishInflate() { super.onFinishInflate(); mButton = (Button) findViewById(R.id.ccbutton_button); mClear = (ImageView) findViewById(R.id.ccbutton_clear); mButton.setText(""); // error here: mButton == null } My problem is similar to this one. When i try to find the views inside the custom compound, findViewById returns null. But, as you can see, i already added super(context, attrs); to the constructor. i am using the custom component directly in xml layout, like this: <LinearLayout> <!-- some stuff --> <de.pockettaxi.widget.ClearableCaptionedButton android:layout_width="fill_parent" android:layout_height="wrap_content" app:caption="to"/> </LinearLayout> can anybody spot something? thanks.

    Read the article

  • Getting Android SDK WebView and TabWidget to play nice

    - by jdandrea
    I’m taking the HelloTabWidget Android example and trying two things: Moving the tabs to the bottom vs. the top (if that’s even desirable from an Android UI POV) Making each tab show a particular WebView in the space above I’ve got this for a layout (high level): <TabHost> <LinearLayout> <FrameLayout> <WebView/> <WebView/> <WebView/> <WebView/> <WebView/> </FrameLayout> <TabWidget/> </LinearLayout> </TabHost> Everything has a width/height set to fill_parent except for the TabWidget which has its layout_height set to wrap_content (and the layout_gravity set to bottom). First thing I noticed is that WebViews don’t show anything until all the parents have width/height set to fill_parent. However, once I do that, they fill the entire display, obscuring the TabWidget. Is there some other trick to making these two views play nicely together?

    Read the article

  • ActivityThread exception in Android?

    - by Praveen Chandrasekaran
    My Log CAT Value: 05-17 15:16:30.572: ERROR/ActivityThread(17448): Activity com.example.brown.Bru_Maps has leaked IntentReceiver android.net.NetworkConnectivityListener$ConnectivityBroadcastReceiver@432e6360 that was originally registered here. Are you missing a call to unregisterReceiver()? 05-17 15:16:30.572: ERROR/ActivityThread(17448): android.app.IntentReceiverLeaked: Activity com.example.brown.Bru_Maps has leaked IntentReceiver android.net.NetworkConnectivityListener$ConnectivityBroadcastReceiver@432e6360 that was originally registered here. Are you missing a call to unregisterReceiver()? 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher.<init>(ActivityThread.java:748) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread$PackageInfo.getReceiverDispatcher(ActivityThread.java:576) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ApplicationContext.registerReceiverInternal(ApplicationContext.java:770) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ApplicationContext.registerReceiver(ApplicationContext.java:757) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ApplicationContext.registerReceiver(ApplicationContext.java:751) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:290) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.net.NetworkConnectivityListener.startListening(NetworkConnectivityListener.java:138) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at com.google.android.maps.MapActivity.onResume(MapActivity.java:232) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1225) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.Activity.performResume(Activity.java:3559) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2838) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2866) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1819) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.os.Handler.dispatchMessage(Handler.java:99) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.os.Looper.loop(Looper.java:123) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread.main(ActivityThread.java:4203) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at java.lang.reflect.Method.invokeNative(Native Method) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at java.lang.reflect.Method.invoke(Method.java:521) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 05-17 15:16:30.572: ERROR/ActivityThread(17448): at dalvik.system.NativeStart.main(Native Method) What is the Activity Thread Exception in Android? Please Help.

    Read the article

  • Android : Customizing tabs on state : How do I make a selector a drawable

    - by Chrispix
    I know how to put the icon on each tab, that is no problem. I also ran across this : Stack Overflow thread on pretty much same thing I followed one of the links from that question, and found this Pretty much, it said use a selector defined in the xml, sure, did that. But there is no id associated w/ it so I am not sure how to get the selector function as a drawable so I can use it as the icon for the tabs. Maybe I am going about this the wrong way.. But this is what I have, and obviously missing something. <selector android:id="@+id/myselector" xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/darklogo" /> <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/lightlogo" /> <!-- Focused states --> <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/lightlogo" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/lightlogo" /> <!-- Pressed --> <item android:state_pressed="true" android:drawable="@drawable/lightlogo" /> </selector> In my code, an example tab is generated using : host.addTab(host.newTabSpec("three") .setIndicator("map",drawables) .setContent(new Intent(this, Map.class))); Right now drawables is just a reference to an drawable image resource. How do I make the selector a drawable? * This is my question *

    Read the article

  • Android AppWidget maps activity problem

    - by Andy Armstrong
    Right. So I have an app widget. It has 4 buttons, one one of the buttons I want it to show me the current location of the user on the map. So - I make a new activity as below: package com.android.driverwidget; import java.util.List; import android.os.Bundle; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.MyLocationOverlay; import com.google.android.maps.Overlay; public class MyLocation extends MapActivity{ public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); MapView myMapView = (MapView)findViewById(R.id.mapview); MapController mapController = myMapView.getController(); List<Overlay> overlays = myMapView.getOverlays(); MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, myMapView); overlays.add(myLocationOverlay); myLocationOverlay.enableMyLocation(); } protected boolean isRouteDisplayed() { return false; } } And then I added the appropriate uses library line to the manifest <activity android:name=".MyLocation" android:label="myLocation"> </activity> <uses-library android:name="com.google.android.maps" /> Ok yet - when I run the app the following errors occur, looks like it cannot find the MapActivity class, im running it on the GoogleApps 1.5 instead of normal android 1.5 as well. http://pastebin.com/m3ee8dba2 Somebody plz help me - i am now dying.

    Read the article

  • possible xml elements in Android resources xmls ?

    - by Vijay C
    I recently came across a forum post in thelink text android developers group. (link below) It has one post which contains following xml. It is xml file which can be used in drawable folder. <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" /> <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected" /> <!-- Focused states --> <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focus" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focus"/> <!-- Pressed --> <item android:state_pressed="true" android:drawable="@drawable/tab_press" /> </selector> Now my question is, where is the documentation which tells me that i can use the following xml tags <selector> , <item>, <color>, <integer-array>, <string-array> and many others tag to create xml resources...? I hope, i have explained what i want to know ?

    Read the article

  • Android "first time" app user tutorial

    - by EGHDK
    I'm trying to create an opening tutorial that consists of four panes for my application, but since I'm new to Android, I want to make sure I'm considering all of my options before marking this task as "complete". I know of three ways, I can only really accomplish one. There are no requirements for this tutorial, but some "wanted features" would be a sliding action to each pane would be nice as well as the image and the bottom (navigation circles) not moving and the title on top not moving. One Way 4 separate activities and 4 separate layouts The red circled items are textViews that are centered horizontally and pushed off the top. The white circled items are imageViews that are centered horizontally and vertically. The purple circled are imageViews that are centered horizontally and pushed off the bottom. Second Way 4 fragments on one activity Fragments were difficult to learn, but the more I read about them/see tutorials on them, they seem to only really be used for tablets. Would it be a valid way to accomplish this? Third Way ViewPager? http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html I've never used this before, but I know it's an option. Final Question Which way is used more often/what's the proper way to implement this? Is there any way to only have the middle part (the image) slide in, but the title (top) and the navigation images (bottom) just change once the image slides in?

    Read the article

  • Android - Custom Widget doesnt update

    - by david
    Hi, I'm trying to make a widget to my app, but it doesnt update. I just need to change the textview text and open an activity when a press a button, but none of them works... the code public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.newswidget); views.setTextViewText(R.id.tvNews, "prueba1"); views.setString(R.id.tvNews, "setText", "prueba3"); Intent intent = new Intent(context, DoctorChatAndroid.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.ibNext, pendingIntent); for (int i = 0; i < appWidgetIds.length; i++) { appWidgetManager.updateAppWidget(i, views); } the layout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageButton android:id="@+id/ibNext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_media_ff" android:layout_alignParentRight="true"/> <ImageButton android:id="@+id/ibLast" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/ic_media_rew" android:layout_toLeftOf="@id/ibNext"/> <TextView android:id="@+id/tvNews" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/nwNoNewAnswer" android:layout_toLeftOf="@id/ibLast"/> </RelativeLayout> the other xml thx a lot!!!

    Read the article

  • Child Activity in Android

    - by Martin Marinov
    So I have two Activities. The main is called Main, and the child one is called Child. When a button is clicked in the main activity it triggers the following piece of code: Intent i = new Intent(Main.this, Child.class); Main.this.startActivity(i); That opens the Child activity. As soon as I call finish() or press the back button within the child activity instead of going back to the main one, the app just closes. Can you give me a hint where the problem might be :( P.S. By trial and error I found out that if edit AndroidManifest.xml and add android:theme="@android:style/Theme.Dialog" within the declaration of Child the back button and calling finish() behaves as expected: closes the child activity and brings the main into focus. The problem is that when I start typing in an EditText the screen starts flickering (rather bizzare). So I can't use it as a dialog. My main activity uses the camera, so that might be making problems. Although when the child activity is started, the onPause event is fired and it stops the camera until onResume is called.

    Read the article

  • Android: Strange out of memory issue

    - by Chrispix
    I am not sure where to start to explain this one. I have a list view with a couple image buttons on each row. When you click the list row, it launches a new activity. If you review some of my other posts, I have had to build my own tabs because of an issue w/ the camera layout. The activity that gets launched for result is a map. If I click on my button to launch the image preview (load an image off the sd card) the application returns from the activity back to the listview activity to the result handler to relaunch my new activity which is nothing more than an image widget. So here is the issue, the image preview on the list view is being done w/ the cursor & listadapter. This makes it pretty simple, but I am not sure how I can put a resized (i.e. smaller bit size not pixel) image as the src for the imgbutton on the fly. So I just resized the image that came off the phone camera. The issue is that I get an out of memory error when it tries to go back and re-launch the 2nd activity. ** My question : is there a way I can build the list adapter easily row by row, where I can resize on the fly (bit wise)? - this would be preferable as I also need to make some changes to the properties of the widgets/elements in each row as I am unable to select a row w/ touch screen b/c of focus issue. (I can use roller ball). ** I know I can do an out of band resize and save of my image, but that is not really what I want to do, but some sample code for that would be nice if that is your suggestion. As soon as I disabled the image on the listview it worked fine again. FYI : This is how I was doing it : String[] from = new String[] { DBHelper.KEY_BUSINESSNAME, DBHelper.KEY_ADDRESS, DBHelper.KEY_CITY, DBHelper.KEY_GPSLONG, DBHelper.KEY_GPSLAT, DBHelper.KEY_IMAGEFILENAME + ""}; to = new int[] { R.id.businessname, R.id.address, R.id.city, R.id.gpslong, R.id.gpslat, R.id.imagefilename }; notes = new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); setListAdapter(notes); Where R.id.imagefilename is a ButtonImage Here is my LogCat 01-25 05:05:49.877: ERROR/dalvikvm-heap(3896): 6291456-byte external allocation too large for this process. 01-25 05:05:49.877: ERROR/(3896): VM won't let us allocate 6291456 bytes 01-25 05:05:49.877: ERROR/AndroidRuntime(3896): Uncaught handler: thread main exiting due to uncaught exception 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): java.lang.OutOfMemoryError: bitmap size exceeds VM budget 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:304) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:149) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:174) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.graphics.drawable.Drawable.createFromPath(Drawable.java:729) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ImageView.resolveUri(ImageView.java:484) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ImageView.setImageURI(ImageView.java:281) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.SimpleCursorAdapter.setViewImage(SimpleCursorAdapter.java:183) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:129) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.CursorAdapter.getView(CursorAdapter.java:150) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.AbsListView.obtainView(AbsListView.java:1057) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ListView.makeAndAddView(ListView.java:1616) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ListView.fillSpecific(ListView.java:1177) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.ListView.layoutChildren(ListView.java:1454) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.AbsListView.onLayout(AbsListView.java:937) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1108) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.onLayout(LinearLayout.java:922) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.FrameLayout.onLayout(FrameLayout.java:294) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:999) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.LinearLayout.onLayout(LinearLayout.java:920) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.widget.FrameLayout.onLayout(FrameLayout.java:294) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.View.layout(View.java:5611) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.ViewRoot.performTraversals(ViewRoot.java:771) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.view.ViewRoot.handleMessage(ViewRoot.java:1103) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.os.Handler.dispatchMessage(Handler.java:88) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.os.Looper.loop(Looper.java:123) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at android.app.ActivityThread.main(ActivityThread.java:3742) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at java.lang.reflect.Method.invokeNative(Native Method) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at java.lang.reflect.Method.invoke(Method.java:515) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) 01-25 05:05:49.917: ERROR/AndroidRuntime(3896): at dalvik.system.NativeStart.main(Native Method) 01-25 05:10:01.127: ERROR/AndroidRuntime(3943): ERROR: thread attach failed I also have a new error when displaying an image : 01-25 22:13:18.594: DEBUG/skia(4204): xxxxxxxxxxx jpeg error 20 Improper call to JPEG library in state %d 01-25 22:13:18.604: INFO/System.out(4204): resolveUri failed on bad bitmap uri: 01-25 22:13:18.694: ERROR/dalvikvm-heap(4204): 6291456-byte external allocation too large for this process. 01-25 22:13:18.694: ERROR/(4204): VM won't let us allocate 6291456 bytes 01-25 22:13:18.694: DEBUG/skia(4204): xxxxxxxxxxxxxxxxxxxx allocPixelRef failed

    Read the article

  • CastClassException on Custom View

    - by tuxGurl
    When I try to findViewById() on my custom view I keep getting a ClassCastException. I've tried so many things that I'm sure I've botched the code now! To make sure I'm not going insane I stripped down the classes to their bare minimum inorder to find what was wrong. I'm new to android programming and I'm sure I'm missing something basic. This is BaseImageView an extended view class. package com.company.product.client.android.gui.views; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.view.View; public class BaseImageView extends View { public BaseImageView(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawColor(Color.GREEN); } } This is LiveImageView an extension of the BaseImageView class. package com.company.product.client.android.gui.views; import android.content.Context; import android.util.AttributeSet; public class LiveImageView extends BaseImageView { public LiveImageView(Context context, AttributeSet attrs) { super(context); } } Here is the Layout my_view.xml. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <View class="com.company.product.client.android.gui.views.LiveImageView" android:id="@+id/lvImage" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> And here is the onCreate in my Activity LiveViewActivity. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { setContentView(R.layout.my_view); final LiveImageView lvImage = (LiveImageView) findViewById(R.id.lvImage); } catch (final Exception e) { Log.e(TAG, "onCreate() Exception: " + e.toString()); e.printStackTrace(); } Finally, this is stack trace. 02-11 17:25:24.829: ERROR/LiveViewActivity(1942): onCreate() Exception: java.lang.ClassCastException: android.view.View 02-11 17:25:24.839: WARN/System.err(1942): java.lang.ClassCastException: android.view.View 02-11 17:25:24.839: WARN/System.err(1942): at com.company.product.client.android.gui.screen.LiveViewActivity.onCreate(LiveViewActivity.java:26) 02-11 17:25:24.839: WARN/System.err(1942): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 02-11 17:25:24.849: WARN/System.err(1942): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 02-11 17:25:24.849: WARN/System.err(1942): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 02-11 17:25:24.849: WARN/System.err(1942): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 02-11 17:25:24.849: WARN/System.err(1942): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 02-11 17:25:24.859: WARN/System.err(1942): at android.os.Handler.dispatchMessage(Handler.java:99) 02-11 17:25:24.859: WARN/System.err(1942): at android.os.Looper.loop(Looper.java:123) 02-11 17:25:24.859: WARN/System.err(1942): at android.app.ActivityThread.main(ActivityThread.java:4363) 02-11 17:25:24.869: WARN/System.err(1942): at java.lang.reflect.Method.invokeNative(Native Method) 02-11 17:25:24.869: WARN/System.err(1942): at java.lang.reflect.Method.invoke(Method.java:521) 02-11 17:25:24.869: WARN/System.err(1942): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 02-11 17:25:24.869: WARN/System.err(1942): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 02-11 17:25:24.879: WARN/System.err(1942): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • PhoneGap's vibrate() and beep() functions break in iPhone, Android emulators

    - by Steve Nay
    I have a PhoneGap app that I'm testing on webOS, Android, and iPhone. I'm using physical devices as well as emulators (the ones that come with their respective SDKs, not the PhoneGap emulator). Part of the code uses the navigator.notification.vibrate() and navigator.notification.beep() functions. All the physical devices I'm using either perform the behavior or ignore it if they're not capable (e.g., the iPod can't vibrate). However, the emulators behave differently. The Android emulator kills the app whenever the beep() function is called. The iPhone emulator causes the app to hang whenever the vibrate() function is called. Is there any way to get the emulators to ignore those function calls when they are unable to execute them? That is, is there a way to get them to degrade gracefully so I can test the app both places without having to modify the code specifically for the emulators?

    Read the article

  • RadioGroup onCheckedChanged function won't fire

    - by user1758088
    First time/long time. My app keeps track of restaurant servers' shift sales to help them budget. In the activity that displays past shifts, I've created a RadioGroup under the ListView so the server can choose lunch, dinner, or both. I've implemented RadioGroup.onCheckedChangeListener, but onCheckChanged never gets called. I also tried an anonymous inner class as listener, same result. I tried to copy/modify code from this answer: http://stackoverflow.com/a/9595528 ...but when I added the @Override to the callback function, the Eclipse compiler gave me an error (not warning) that the method must override a superclass, and the quick fix was to remove the override. I'm pretty sure the signatures are correct, as they were made with Eclipse's autocomplete and implement methods facilities. I then followed instructions to move my java compiler from 1.5 to 1.6, and none of the above listed behavior seemed to change. Here's the code I thing is relavent: public class DataActivity extends ListActivity implements OnCheckedChangeListener{ RadioButton rbBoth; RadioButton rbDinnerOnly; RadioButton rbLunchOnly; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.database); ... final RadioGroup rgGroup = (RadioGroup)findViewById(R.id.DataRadioGroup); rbBoth = (RadioButton)findViewById(R.id.RadioBoth); rbDinnerOnly = (RadioButton)findViewById(R.id.RadioDinnerOnly); rbLunchOnly = (RadioButton)findViewById(R.id.RadioLunchOnly); rgGroup.setOnCheckedChangeListener(this); populateAllShifts(); } ... public void onCheckedChanged(RadioGroup group, int checkedId) { rbLunchOnly.setText("Click!"); Toast.makeText(getApplicationContext(), "Lunch Only", Toast.LENGTH_LONG).show(); if(group.getCheckedRadioButtonId() == R.id.RadioBoth){ populateAllShifts(); return; } if(group.getCheckedRadioButtonId() == R.id.RadioLunchOnly){ populatLunchShifts(); return; } if(group.getCheckedRadioButtonId() == R.id.RadioDinnerOnly){ populateDinnerShifts(); return; } } There is a ListView in this class with a custom adapter, but if my understanding and my XML are correct, the RadioGroup should be outside of the list: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/llDataLayout" android:weightSum="5" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ListView android:layout_weight="4" android:layout_width="fill_parent" android:id="@android:id/list" android:layout_height="wrap_content"></ListView> <RadioGroup android:layout_weight="1" android:id="@+id/DataRadioGroup" android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent"> <RadioButton android:text="Lunch and Dinner" android:textSize="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/RadioBoth"/> <RadioButton android:text="Dinner Only" android:textSize="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/RadioDinnerOnly"/> <RadioButton android:text="Lunch Only" android:textSize="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/RadioLunchOnly"/> </RadioGroup> </LinearLayout> Any ideas out there?

    Read the article

  • How to set my .apk file to run on different screen resolution in android?

    - by Arslan
    I am using a "WVGA800" for my app. I try to run it on different resolution screens. It it is not perfectly scratching in that resolution . I read and implement issues form this link. http://developer.android.com/guide/practices/screens_support.html But still not result. Please let me know if any one hase a perfect solution. Main issue are that I am fixing hight & width of Image, textsize etc. When these are displayed to screen of "WVGA800". But when I test them on "HVGA", "QVGA" then problem arise. I want to avoid the "if else" conditions by getting the screen resolution at Runtime. If any one hase any solution for this...let me know. Thanks in advance. I am also wondring when there will be new devices with new screen resolutions?

    Read the article

  • Android popup style activity which sits on top of any other apps

    - by RenegadeAndy
    What I want to create is a popup style application. I have a service in the background - something arrives on the queue and i want an activity to start to inform the user - very very similar to the functionality of SMSPopup app. So I have the code where something arrives on the queue and it calls my activity. However for some reason the activity always shows on top of the originally started activity instead of just appearing on the main desktop of the android device. As an example: I have the main activity which is shown when the application is run I have the service which checks queue I have a popup activity. When i start the main activity it starts the service - I can now close this. I then have something on the queue and it creates the popup activity which launches the main activity with the popup on top of it :S How do I stop this and have it behave as i want... The popup class is : package com.andy.tabletsms.work; import com.andy.tabletsms.tablet.R; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.PopupWindow; import android.widget.TextView; import android.widget.Toast; public class SMSPopup extends Activity implements OnClickListener{ public static String msg; @Override public void onCreate(Bundle bundle){ super.onCreate(bundle); // Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show(); this.setContentView(R.layout.popup); TextView tv = (TextView)findViewById(R.id.txtLbl); Intent intent = getIntent(); if (intent != null){ Bundle bb = intent.getExtras(); if (bb != null){ msg = bb.getString("com.andy.tabletsms.message"); } } if(msg == null){ msg = "LOLOLOL"; } tv.setText(msg); Button b = (Button)findViewById(R.id.closeBtn); b.setOnClickListener(this); } @Override public void onClick(View v) { this.finish(); } } and I call the activity from a broadcast receiver which checks the queue every 30 seconds or so : if(main.msgs.size()0){ Intent testActivityIntent = new Intent(context.getApplicationContext(), com.andy.tabletsms.work.SMSPopup.class); testActivityIntent.putExtra("com.andy.tabletsms.message", main.msgs.get(0)); testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(testActivityIntent); } The layout is here : http://pastebin.com/F25u6wdM

    Read the article

  • Tunning up Activity with dialog theme

    - by Gaks
    I need to launch a Dialog from home screen widget, so I created an Activity with android:theme="@android:style/Theme.Dialog" The problem is, that I would like make it look like standard dialog window ( buttons on the gray background, font and text size, paddings etc), like here: This is how my "dialog" Activity looks like: Is there some standard way (theme?) to make it look like standard system dialogs? Or do I have to imitate it in my own layout?

    Read the article

  • HelloWebView Sample: now using SDK 3 and getting killed

    - by Tim
    Hey Folks, Well I was trying to get the HelloWebview example working with SDK 7 with no success (see HelloWebView Sample: java.lang.SecurityException: Permission Denial thread), so I decided just out of curiosity to back off to SDK3 to see if I could learn anything. I have been able to get all the "Layout" samples to work and decided to try something a little harder. Unfortunately, I still cannot get the simple HelloWebView app to run. I no longer get a Permission Denial but now the app is getting killed. Killed usually implies that there are not enough resources (memory etc.) for an application to run.... Any thoughts? Are there any other log files I can look at either on my computer or on the emulator? The main.xml, manifest, and console output are below. Let me know if you need more information. Thanks, Tim main.xml: <?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" > <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </LinearLayout> mainfest file: <uses-permission android:name="android.permission.INTERNET" /> <uses-sdk android:minSdkVersion="3" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloWebView3" 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=".HelloWebView3" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> </activity> </application> Console output: [2010-06-05 08:43:37 - HelloWebView3] ------------------------------ [2010-06-05 08:43:37 - HelloWebView3] Android Launch! [2010-06-05 08:43:37 - HelloWebView3] adb is running normally. [2010-06-05 08:43:37 - HelloWebView3] Performing com.example.hellowebview3.HelloWebView3 activity launch [2010-06-05 08:43:37 - HelloWebView3] Automatic Target Mode: launching new emulator with compatible AVD 'Android1.5' [2010-06-05 08:43:37 - HelloWebView3] Launching a new emulator with Virtual Device 'Android1.5' [2010-06-05 08:43:42 - HelloWebView3] New emulator found: emulator-5554 [2010-06-05 08:43:42 - HelloWebView3] Waiting for HOME ('android.process.acore') to be launched... [2010-06-05 08:45:04 - HelloWebView3] HOME is up on device 'emulator-5554' [2010-06-05 08:45:04 - HelloWebView3] Uploading HelloWebView3.apk onto device 'emulator-5554' [2010-06-05 08:45:04 - HelloWebView3] Installing HelloWebView3.apk... [2010-06-05 08:45:19 - HelloWebView3] Success! [2010-06-05 08:45:19 - HelloWebView3] Starting activity com.example.hellowebview3.HelloWebView3 on device [2010-06-05 08:45:23 - HelloWebView3] ActivityManager: Starting: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} comp={com.example.hellowebview3/com.example.hellowebview3.HelloWebView3} } [2010-06-05 08:45:23 - HelloWebView3] ActivityManager: [1] Killed am start -n com....

    Read the article

  • Android manifest

    - by Venkatesh
    hi friends, I am having two package in my application 1.com.fsp.deals and 2.com.facebook.android.. i declared my package as package =com.fsp.deals in Manifest file.. if i want to use the activity in com.facebook.android how i should call activity in manifest file it showing error as i define as </activity> <activity android:name="com.facebook.android.Example" android:screenOrientation="portrait" android:label="@string/app_name" android:windowSoftInputMode="stateUnspecified|adjustPan"> </activity>

    Read the article

  • add android support library v4 to intellij ide

    - by user1233587
    i am trying to use viewpager from android support library v4 in intelli j currently i have android sdk 4.1 I copied android-support-v4.jar to my intellij android project under 'libs' in the project settings of intellij I webt to "Modules" = "MyModuleName" = dependencies tab, and add the android-support-v4.jar, by navigating the path to the libs/ folder under my own project I checked the 'export' besides this newly added jar file but i still can't use viewpager in my application i get a crash msg like java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxx/com.xxxx.MyActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class android.support.v4.view.ViewPager

    Read the article

  • How to receive sms from a special phone number?

    - by Pariya
    I wrote a send and receive sms in android successfully. I want my program to be able to receive sms from a special number("+9856874236"). But, if the SMS is from any other number, it should go to the phone's message inbox and not to my application. import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsMessage; import android.util.Log; public class SmsReceiver extends BroadcastReceiver { public String str = ""; @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); Object messages[] = (Object[]) bundle.get("pdus"); SmsMessage[] msgs = null; if (bundle != null) { Object[] pdus = (Object[]) bundle.get("pdus"); SmsMessage smsMessage[] = new SmsMessage[messages.length]; String msg_from=""; for (int n = 0; n < messages.length; n++) { smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]); msg_from += msgs[n].getOriginatingAddress(); } String receivedMessage = smsMessage[0].getMessageBody().toString().toUpperCase(); if(msg_from .equals("+989124236870")) { for (int n = 0; n < messages.length; n++) { smsMessage[n] = SmsMessage.createFromPdu((byte[]) pdus[n]); str += "SMS from " + msgs[n].getOriginatingAddress(); str += " :"; //str += "sms az shomare makhsus"; str += msgs[n].getMessageBody().toString(); str += "\n"; abortBroadcast(); } Intent act = new Intent(context, MainActivity.class); act.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); act.putExtra("message", str); context.startActivity(act); } } } }

    Read the article

  • Android Camera intent creating two files

    - by Kyle Ramstad
    I am making a program that takes a picture and then shows it's thumbnail. When using the emulator all goes well and the discard button deletes the photo. But on a real device the camera intent saves the image at the imageUri variable and a second one that is named like if I had just opened up the camera and took a picture by itself. private static final int CAMERA_PIC_REQUEST = 1337; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera); //start camera values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "New Picture"); values.put(MediaStore.Images.Media.DESCRIPTION,"From your Camera"); imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); image = (ImageView) findViewById(R.id.ImageView01); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, CAMERA_PIC_REQUEST); //save the image buttons Button save = (Button) findViewById(R.id.Button01); Button close = (Button) findViewById(R.id.Button02); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) { try{ thumbnail = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri); image.setImageBitmap(thumbnail); } catch(Exception e){ e.printStackTrace(); } } else{ finish(); } } public void myClickHandler(View view) { switch (view.getId()) { case R.id.Button01: finish(); break; case R.id.Button02: dicard(); } } private void dicard(){ getContentResolver().delete(imageUri, null, null); finish(); }

    Read the article

  • Multiple dex files define Lcom/google/api/client/auth/oauth/AbstractOAuthGetToken;

    - by Elad Benda
    I have just followed this tutorial: https://developers.google.com/drive/quickstart-android so I don't see a reason for duplicated libs in my project. I have added the drive Client lib via Google plugin for eclipse When I build my android app with this manifest <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="16" /> <uses-permission android:name="android.permission.READ_CALENDAR" /> <uses-permission android:name="android.permission.WRITE_CALENDAR" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.GET_ACCOUNTS"/> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/todo" android:label="@string/app_name" > <activity android:name=".TodosOverviewActivity" 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=".TodoDetailActivity" android:windowSoftInputMode="stateVisible|adjustResize" > <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="image/*" /> </intent-filter> </activity> <provider android:name=".contentprovider.MyTodoContentProvider" android:authorities="de.vogella.android.todos.contentprovider" > </provider> </application> I get the following error: [2013-10-27 00:43:58 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/api/client/auth/oauth/AbstractOAuthGetToken; [2013-10-27 00:43:58 - de.vogella.android.todos] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/api/client/auth/oauth/AbstractOAuthGetToken; how can I fix this?

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >