Search Results

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

Page 25/482 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • How to launch activity from android home screen widget

    - by Brian515
    Hi all, I am desperately trying to get my head wrapped around how to implement home screen widgets. Right now, I (finally) was able to get a button on my widget respond to a button press setting up an intent filter in the manifest. However, I cannot for the life of me figure out how to launch an activity when the button is pressed. Basically, here's the code i have: @Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); if(intent.getAction().equals("com.bic.search.searchWidget.CLICK")) { Toast.makeText(context, "It works!!", Toast.LENGTH_SHORT).show(); } } What I really want to do, though, is start a new activity, not display a toast message. I know it has something to do with pending intents, but I can't figure out how to get that to work. Any help and sample code would be appreciated. Thanks a ton to whoever answers this!

    Read the article

  • Android -- How to position View off-screen?

    - by borg17of20
    Hello all, I'm trying to animate a simple ImageView in my application and I want it to slide in from the bottom of the screen and come to a resting position where the top 50px of the view is off the top of the screen (e.g. the final position of the ImageView should be -50px in X). I've tried to use the AbsoluteLayout to do this, but this actually cuts off the top 50px of the ImageView such that the top 50px is never rendered. I need to have the top 50px of the ImageView visible/rendered while it's animating and then simply have it come to a rest slightly off-screen. I hope I've explained that well enough. Here is what I'm currently using as a layout and the slide-in animation (this currently doesn't render the top 50px of the ImageView): Layout: <?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/QuickPlayClipLayout"> <ImageView android:id="@+id/Clip" android:background="@drawable/clip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_y="-50dp"> </ImageView> </AbsoluteLayout> Animation: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="1000"/> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" /> </set> Thanks in advance.

    Read the article

  • android spinner width problem?

    - by UMMA
    dear friends, i have created following layout. <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TableRow> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Post As" /> <Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ddlPostAs" /> </TableRow> <TableRow> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Expires In" /> <Spinner android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ddlExpiryOn" /> </TableRow> </TableLayout> in which android spinner changes its width according to the data. i want to stop it. can any one guide me how to achieve this? any help would be appriciated.

    Read the article

  • Xamarin Designer for Android Webinar - Recording

    - by Wallym
    Here is some info on the recording of the webinar that I did last week for AppDev regarding the Xamarin Designer for Android.Basic Info: Android user interfaces can be created declaratively by using XML files, or programmatically in code. The Xamarin Android Designer allows developers to create and modify declarative layouts visually, without having to deal with the tedium of hand-editing XML files. The designer also provides real-time feedback, which lets the developer validate changes without having to redeploy the application in order to test a design. This can speed up UI development in Android tremendously. In this webinar, we'll take a look at UI Design in Mono for Android, the basics of the Xamarin Android Designer, and build a simple application with the designer.Here is the link:http://media.appdev.com/EDGE/LL/livelearn05232012.wmvI think it will only play in Internet Explorer.  Enjoy!

    Read the article

  • Stop Progressbar manual scrolling in Android

    - by Rony
    Hi experts, I have already posted my query here, but unfortunately, not getting the required support for this simple query. http://www.anddev.org/prevent_manual_moving_of_seekbar_widget-t13048.html I am using progressbar widget in my application to show the download progress. In the current state, I am able to manually move the slider back and forth while download is progressing. How can I prevent the manual moving of progressbar, instead it works only based on progressbar.setProgress(progressbar.getProgress() + 1024); -- currently this works perfect, but I need to prevent the manual moving of progressbar during download. Any help in this regard is appreciated. Regards, Rony

    Read the article

  • Android ignores scrollbarsize

    - by Maragues
    Hi, I'm trying to modify a ListView scrollbar's width without success <ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:choiceMode="singleChoice" android:scrollbars="vertical" android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track" android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb" android:scrollbarSize="4px" android:clickable="true"/> First I tried using a drawable image 4px wide, but the .png was resized. Then I tried using a shape extracted from SamplesApi, without success. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:width="40px"> <gradient android:startColor="#505050" android:endColor="#C0C0C0" android:angle="0"/> <corners android:radius="0dp" /> I've tried with and without the android:width attribute. There's a question on the same topic (http://stackoverflow.com/questions/2565083/width-of-a-scroll-bar-in-android), but it doesn't try anything different that what I'm already trying. As far as I know, creating my own theme shouldn't change the output. There's an example in SamplesApi (Views/ScrollBars). I tried modifying the scrollbarSize attribute without result. I know about ninepatch images, but there's an attribute which should do what I want. Any hint? Thanks in advance.

    Read the article

  • Android 2.2 SDK breaks compatibility with older phones

    - by Tom
    I have recently updated my app to a build tarket of SDK version 8 in order to include the App2SD feature for my users. However I have had reports of devices on SDK 3 (1.5) having problems starting the application, with the following stack trace: ... E/AndroidRuntime(10638): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/title_bar_shadow.9.png from drawable resource ID #0x7f020000 E/AndroidRuntime(10638): at android.content.res.Resources.loadDrawable(Resources.java:1641) E/AndroidRuntime(10638): at android.content.res.TypedArray.getDrawable(TypedArray.java:548) E/AndroidRuntime(10638): at android.view.View.<init>(View.java:1726) E/AndroidRuntime(10638): at android.view.View.<init>(View.java:1675) E/AndroidRuntime(10638): at android.view.ViewGroup.<init>(ViewGroup.java:271) E/AndroidRuntime(10638): at android.widget.LinearLayout.<init>(LinearLayout.java:92) E/AndroidRuntime(10638): ... 26 more E/AndroidRuntime(10638): Caused by: java.io.FileNotFoundException: res/drawable/title_bar_shadow.9.png E/AndroidRuntime(10638): at android.content.res.AssetManager.openNonAssetNative(Native Method) E/AndroidRuntime(10638): at android.content.res.AssetManager.openNonAsset(AssetManager.java:392) E/AndroidRuntime(10638): at android.content.res.Resources.loadDrawable(Resources.java:1634) E/AndroidRuntime(10638): ... 31 more If i change the build target back to version 4 as it was previously this issue goes away, also if i remove any graphical resources from my XML files this issue goes away! Any help would be much appreciated as i currently have a broken app on the market for many users.

    Read the article

  • How to delete a contact in android 2.1

    - by Rishabh
    Hi, I have added one contact to android by following code. ContentValues values = new ContentValues(); Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); long rawContactId = ContentUris.parseId(rawContactUri); values.clear(); values.put(Data.RAW_CONTACT_ID, rawContactId); values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); getContentResolver().insert(Data.CONTENT_URI, values); It shows up on emulator 2.1, but when i am going to delete it manually by "delete contact" option, its not deleteing from emulator. If I edit some thing on it then only it deletes. How can i directly delete it from menu ? Thanks in advance...

    Read the article

  • Andrioid shake detection on emulator

    - by cppdev
    Hi, I am pretty new to android. I have a use case where I need to detect a shake and show some images in my application. Can I test shake functionality on android emulator ? What are the other alternatives apart from testing it on a real phone ?

    Read the article

  • Find package name for Android apps to use Intent to launch Market app

    - by eom
    I'm creating a mobile website that will include a page from which people can download relevant apps that we recommend. I've found good instructions for creating the links to launch the Market but this assumes that you are the developer of the app in question and know the exact package name. Is there any way to get the package name, other than just contacting the developers and asking? For the iPhone, I found easy instructions for getting the URL I need from the iTunes store, so I'm looking for info like that.

    Read the article

  • Android TextView Linkify problem with phone numbers and application version number

    - by Gaks
    I have a problem with TextView and autoLink feature. I have an about screen in my application with some information like support phone number, email address, website URL and application version in form like 01.01.01 After setting autoLink="all" on the textView, all values are linked fine - except that version number 01.01.01 is linked as the phone number as well. Is there some way to exclude this text fragment from linkifing?

    Read the article

  • android camera preview blank screen

    - by user1104836
    I want to capture a photo manually not by using existing camera apps. So i made this Activity: public class CameraActivity extends Activity { private Camera mCamera; private Preview mPreview; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); // Create an instance of Camera // mCamera = Camera.open(0); // Create our Preview view and set it as the content of our activity. mPreview = new Preview(this); mPreview.safeCameraOpen(0); FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview); preview.addView(mPreview); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_camera, menu); return true; } } This is the CameraPreview which i want to use: public class Preview extends ViewGroup implements SurfaceHolder.Callback { SurfaceView mSurfaceView; SurfaceHolder mHolder; //CAM INSTANCE ================================ private Camera mCamera; List<Size> mSupportedPreviewSizes; //============================================= /** * @param context */ public Preview(Context context) { super(context); mSurfaceView = new SurfaceView(context); addView(mSurfaceView); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = mSurfaceView.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } /** * @param context * @param attrs */ public Preview(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } /** * @param context * @param attrs * @param defStyle */ public Preview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } /* (non-Javadoc) * @see android.view.ViewGroup#onLayout(boolean, int, int, int, int) */ @Override protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) { // TODO Auto-generated method stub } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // Now that the size is known, set up the camera parameters and begin // the preview. Camera.Parameters parameters = mCamera.getParameters(); parameters.setPreviewSize(width, height); requestLayout(); mCamera.setParameters(parameters); /* Important: Call startPreview() to start updating the preview surface. Preview must be started before you can take a picture. */ mCamera.startPreview(); } @Override public void surfaceCreated(SurfaceHolder holder) { // TODO Auto-generated method stub } @Override public void surfaceDestroyed(SurfaceHolder holder) { // Surface will be destroyed when we return, so stop the preview. if (mCamera != null) { /* Call stopPreview() to stop updating the preview surface. */ mCamera.stopPreview(); } } /** * When this function returns, mCamera will be null. */ private void stopPreviewAndFreeCamera() { if (mCamera != null) { /* Call stopPreview() to stop updating the preview surface. */ mCamera.stopPreview(); /* Important: Call release() to release the camera for use by other applications. Applications should release the camera immediately in onPause() (and re-open() it in onResume()). */ mCamera.release(); mCamera = null; } } public void setCamera(Camera camera) { if (mCamera == camera) { return; } stopPreviewAndFreeCamera(); mCamera = camera; if (mCamera != null) { List<Size> localSizes = mCamera.getParameters().getSupportedPreviewSizes(); mSupportedPreviewSizes = localSizes; requestLayout(); try { mCamera.setPreviewDisplay(mHolder); } catch (IOException e) { e.printStackTrace(); } /* Important: Call startPreview() to start updating the preview surface. Preview must be started before you can take a picture. */ mCamera.startPreview(); } } public boolean safeCameraOpen(int id) { boolean qOpened = false; try { releaseCameraAndPreview(); mCamera = Camera.open(id); mCamera.startPreview(); qOpened = (mCamera != null); } catch (Exception e) { // Log.e(R.string.app_name, "failed to open Camera"); e.printStackTrace(); } return qOpened; } Camera.PictureCallback mPicCallback = new Camera.PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) { // TODO Auto-generated method stub Log.d("lala", "pic is taken"); } }; public void takePic() { mCamera.startPreview(); // mCamera.takePicture(null, mPicCallback, mPicCallback); } private void releaseCameraAndPreview() { this.setCamera(null); if (mCamera != null) { mCamera.release(); mCamera = null; } } } This is the Layout of CameraActivity: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".CameraActivity" > <FrameLayout android:id="@+id/camera_preview" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" /> <Button android:id="@+id/button_capture" android:text="Capture" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> </LinearLayout> But when i start the CameraActivity, i just see a blank white background and the Capture-Button??? Why i dont see the Camera-Screen?

    Read the article

  • Ghost activity in android

    - by Ari
    My application works as follow: On start I have some AppStartActivity which does something, finishes itself and starts MainActivity if user is logged in or LoginActivity otherwise. LoginActivity finishes itself and starts MainActivity when user log in successfully. On MainActivity I have SomeActivity from which user can logout. Activity stack for this situation is MainActivity > SomeActivity. It is correct, back button works well. When user click LogOut button there is a problem. I need to show LoginActivity but I don't want to have MainActivity and SomeActivity on activity stack anymore. I could resolve this problem if I wouldn't finish AppStartActivity. I could go back then with flag FLAG_ACTIVITY_CLEAR_TOP and it would work well. But here is a problem with back button. I don't want user to come back to this activity with back button. I want it to exit app instead. UPDATED: Flags FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK would be best, but I need it working in API level 9.

    Read the article

  • Android Activity ClassNotFoundException - tried everything

    - by Matthew Rathbone
    I've just refactored an app into a framework library and an application, but now when I try and start the app in the emulator I get the following error stack trace: 06-02 18:22:35.529: E/AndroidRuntime(586): FATAL EXCEPTION: main 06-02 18:22:35.529: E/AndroidRuntime(586): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.matthewrathbone.eastersays/com.matthewrathbone.eastersays.EasterSimonSaysActivity}: java.lang.ClassNotFoundException: com.matthewrathbone.eastersays.EasterSimonSaysActivity in loader dalvik.system.PathClassLoader[/data/app/com.matthewrathbone.eastersays-1.apk] 06-02 18:22:35.529: E/AndroidRuntime(586): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.os.Handler.dispatchMessage(Handler.java:99) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.os.Looper.loop(Looper.java:123) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.app.ActivityThread.main(ActivityThread.java:4627) 06-02 18:22:35.529: E/AndroidRuntime(586): at java.lang.reflect.Method.invokeNative(Native Method) 06-02 18:22:35.529: E/AndroidRuntime(586): at java.lang.reflect.Method.invoke(Method.java:521) 06-02 18:22:35.529: E/AndroidRuntime(586): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 06-02 18:22:35.529: E/AndroidRuntime(586): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 06-02 18:22:35.529: E/AndroidRuntime(586): at dalvik.system.NativeStart.main(Native Method) 06-02 18:22:35.529: E/AndroidRuntime(586): Caused by: java.lang.ClassNotFoundException: com.matthewrathbone.eastersays.EasterSimonSaysActivity in loader dalvik.system.PathClassLoader[/data/app/com.matthewrathbone.eastersays-1.apk] 06-02 18:22:35.529: E/AndroidRuntime(586): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 06-02 18:22:35.529: E/AndroidRuntime(586): at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 06-02 18:22:35.529: E/AndroidRuntime(586): at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 06-02 18:22:35.529: E/AndroidRuntime(586): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 06-02 18:22:35.529: E/AndroidRuntime(586): ... 11 more Usually this means that the manifest file is wrong in some way, but I've double checked everything I can think of. Here is my activity class: package com.matthewrathbone.eastersays; import android.os.Bundle; import com.rathboma.simonsays.Assets.Season; import com.rathboma.simonsays.SeasonPicker; import com.rathboma.simonsays.SimonSaysActivity; public class EasterSimonSaysActivity extends SimonSaysActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); } @Override public SeasonPicker getSeasonPicker() { return new SeasonPicker(){ @Override public Season getSeason() { // TODO Auto-generated method stub return Season.EASTER; } }; } } As you can see, it's listed correctly in the manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.matthewrathbone.eastersays" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".EasterSimonSaysActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> I have no idea how to fix this, and would appreciate any help. I've scanned many similar questions on SO without seeing this particular behavior. More info: I've checked inside the generated APK and the class has an entry in the classes.dex file I've tried cleaning/building the project in eclipse I've tried using a totally new device image that doesn't have a copy of the APK on it already I've changed the library project into a regular java, then changed back into an android project, no difference

    Read the article

  • Reference for good Android UI design patterns.

    - by sat
    Hi, I would like to get some links for getting started with design patterns.My requirement is , (at Initial stage) How to go about developing a particular pattern , say customized ListView which can be shared across applications . e.g. Applications will call something like drawCustomizedListView(params...) and my code will draw the listview according to the parameters supplied. This is particularly useful when across the applications I have to draw customized views. My intention is, I should not repeat the same code everywhere for doing similar task. Any references for the above requirement ?

    Read the article

  • Android - Correspondence between ImageView coordinates and Bitmap Pixels

    - by Matteo
    In my application I want the user to be able to select some content of an Image contained inside an ImageView. To select the content I subclassed the ImageView class making it implement the OnTouchListener so to draw over it a rectangle with borders decided by the user. Here is an example of the result of the drawing (to have an idea you can think of it as when you click with the mouse on your desktop and drag the mouse): Now I need to determine which pixels of the Bitmap image correspond to the selected part. It's kind of easy to determine which are the points of the ImageView belonging to the rectangle, but I don't know how to get the correspondent pixels, since the ImageView has a different aspect ratio than the original image. I followed the approach described especially here, but also here, but am not fully satisfied because in my opinion the correspondence made is 1 on 1 between pixels and points on the ImageView and does not give me all the correspondent pixels on the original image to the selected area. Calling hoveredRect the rectangle on the ImageView the points inside of it are: class Point { float x, y; @Override public String toString() { return x + ", " + y; } } Vector<Point> pointsInRect = new Vector<Point>(); for( int x = hoveredRect.left; x <= hoveredRect.right; x++ ){ for( int y = hoveredRect.top; y <= hoveredRect.bottom; y++ ){ Point pointInRect = new Point(); pointInRect.x = x; pointInRect.y = y; pointsInRect.add(pointInRect); } } How can I obtain a Vector<Pixels> pixelsInImage containing the correspondent pixels?

    Read the article

  • how can i get proper Uri of a particular contact in android 2.1

    - by Rishabh
    I have written an application and added 2 contacts on emulator, but i am not able to update their names on android 2.1, code is working on android 1.6 platform with the following code. ContentValues contactValues = new ContentValues(); contactValues.put(Contacts.People.NAME, firstName+" "+lastName); getContentResolver().update(UpdateContactUri, contactValues, null, null); In android 1.6 i am getting Uri for those two contacts are "content:// contacts/people/1" and "content://contacts/people/2". but in 2.1 I am getting these values are "content://contacts/people/8" and "content://contacts/people/9" and while updating its giving "java.IllegalArgumentException, Empty values" exception. When i tried to put a static Uri like "content://contacts/people/1", code was debugged sucessfully but contact was not updated. How can i resolve it, why i am not getting uri like 1.6 platform ? Thanks in advance...

    Read the article

  • Will a mulitouch touch screen equipped PC allow me to simulate real Android UI's without an Android device ?

    - by Scott Davies
    Hi, I have recently purchased a Samsung Galaxy Tab as an Android 2.x testbed (I am aware that 2.3 might not run on it, but it appears to be a good 1.x - 2.x device with a large enough screen to approximate the variety of screens on different phones). I would wait for Honeycomb equipped devices (such as the Motorola XOOM mentioned at CES 2011), but these are slated for some time in Q1 (likely end of Q1 for the Canadian market). If I get a multitouch capable PC and install the Android SDK and simulator, will I be able to use the multitouch functionality of the PC with the simulator to approximate a real device ? Does anyone use a multitouch touch screen PC for Android development ? I assume that this would work as the PC would recognize my fingers like the mouse, but I'd like to find out before purchasing the PC. Thanks for your help, Scott

    Read the article

  • Android EditText within a ListView

    - by metalideath
    I have created a custom Array Adapter to bind a custom row that contains some static text and an editable EditText. I am trying to register to be notified when the user changes the text within the edit text and when notified to determine which ArrayList row the modified EditText corresponds to. In the past with other types of views such as a Spinner I could simply put a reference to the parent view and the row number into the tag for the Spinner view. And then when I was notified that the value changed I read the tag to determine how to correlate it back to the master ArrayList. The problem with registering to be notifed with an EditText change is that you do not get back a view but instead get a TextWatcher and I have no way to correlate back to the parent view or ArrayList row. What is the technique that you need to use in this circumstance?

    Read the article

  • How can i do the same thing with Gallery in Android

    - by Maxood
    I am navigating images with the clicks of next and previous buttons.Here is my code: package com.myapps.imagegallery; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; public class ImageGallery extends Activity { /** Called when the activity is first created. */ int imgs[] = {R.drawable.bluehills,R.drawable.lilies,R.drawable.sunset,R.drawable.winter}; String desc[] = {"Blue Hills", "Lillies", "Sunset", "Winter" }; int counter=0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView imgView = (ImageView)findViewById(R.id.ImageView01); imgView.setImageResource(imgs[counter]); final TextView tvDesc = (TextView)findViewById(R.id.tvDesc); Button btnNext = (Button)findViewById(R.id.btnNext); btnNext.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View arg0) { try{ // TODO Auto-generated method stub if (counter < desc.length -1) counter++; imgView.setImageResource(imgs[counter]); tvDesc.setText(desc[counter]); }catch(Exception e) { Toast.makeText(ImageGallery.this, e.toString(), Toast.LENGTH_SHORT).show(); } } }); Button btnPrev = (Button)findViewById(R.id.btnPre); btnPrev.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub try{ // TODO Auto-generated method stub if (counter > 0) counter--; imgView.setImageResource(imgs[counter]); tvDesc.setText(desc[counter]); }catch(Exception e) { Toast.makeText(ImageGallery.this, e.toString(), Toast.LENGTH_SHORT).show(); } }}); } } <?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/ImageView01" android:layout_x="70dip" android:layout_width="200px" android:layout_height="200px" android:layout_y="90dip" > </ImageView> <TextView android:id="@+id/tvDesc" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:layout_x="90px" android:layout_y="300px" /> <Button android:layout_x="47dip" android:layout_height="wrap_content" android:text="Previous" android:layout_width="100px" android:id="@+id/btnPre" android:layout_y="341dip"> </Button> <Button android:layout_x="190dip" android:layout_height="wrap_content" android:text="Next" android:layout_width="100px" android:id="@+id/btnNext" android:layout_y="341dip"> </Button> </AbsoluteLayout>

    Read the article

  • Android strace in Real device

    - by Martin Solac
    I have the following situation, I want to monitor the system calls on Android phones so I made an script to do that. With Android Emulator works perfectly (writes the traces of the application in a specific file on my Ubuntu). The problem is when I attach a real phone to analyze it, it says the following in the result file: ptrace attach failed: Operation not permitted I'm using this code to get it, but I don't understand why it works on the emulator and not in the rooted real device. This is the comand I use in perl: system("$dirTools/adb -s $Device shell strace -p $PID[1]>$dirRecordDataSet/$Date/$appName &"); Any suggestion? Thanks in advance

    Read the article

  • Can't get ellipsis to work on Android

    - by Mark
    Hi, I have a TextView. I want it to ellipsize if longer than its available width. This does not work unless the input string has no spaces... can anyone provide an example of this working? I've tried different combinations of: singleLine="true" maxLines="1" scrollHorizontally="false" none of these have any effect. Again, if I supply a string that has no spaces in it, then the ellipsis appears correctly. What am I missing? I've tried this on 1.5, 1.6, 2.0, all same problem. Thanks

    Read the article

  • Android ListView: how to select an item?

    - by mmo
    I am having trouble with a ListView I created: I want an item to get selected when I click on it. My code for this looks like: protected void onResume() { ... ListView lv = getListView(); lv.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) { Log.v(TAG, "onItemSelected(..., " + pos + ",...) => selected: " + getSelectedItemPosition()); } public void onNothingSelected(AdapterView<?> adapterView) { Log.v(TAG, "onNothingSelected(...) => selected: " + getSelectedItemPosition()); } }); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) { lv.setSelection(pos); Log.v(TAG, "onItemClick(..., " + pos + ",...) => selected: " + getSelectedItemPosition()); } }); ... } When I run this and click e.g. on the second item (i.e. pos=1) I get: 04-03 23:08:36.994: V/DisplayLists(663): onItemClick(..., 1,...) => selected: -1 i.e. even though the OnItemClickListener is called with the proper argument and calls a setSelection(1), there is no item selected (and hence also OnItemSelectedListener.onItemSelected(...) is never called) and getSelectedItemPosition() still yields -1 after the setSelection(1)-call. What am I missing? Michael PS.: My list does have =2 elements...

    Read the article

  • Does "Ubuntu for Android" (12.04) work with the Samsung Galaxy S2?

    - by Charles Hadeed
    I'm trying to buy a new Android phone and I own an Ubuntu 12.04 computer... I have the choice of a Google Galaxy Nexus, Samsung Galaxy S2, and a HTC Sensation XL. I am aware that the HTC already works with it but i would prefer to buy the samsung. I already have the phone hardware specifications and have checked but i am not sure with the samsung or the nexus. So which of these phones work for Ubuntu 12.04's 'Ubuntu for Android' feature?

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >