Search Results

Search found 15838 results on 634 pages for 'android layout'.

Page 14/634 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Android Evolution Marches On [Wallpaper]

    - by Asian Angel
    A newer, stronger Droid cometh… Note: The original size of the comic image is 1996*402 pixels, but it can be easily resized and placed on a white background to best fit your monitor’s resolution. Original image comes in .png format with a transparent background. Robot Evolution [Manu Cornet - Bonkers World Blog] Our Geek Trivia App for Windows 8 is Now Available Everywhere How To Boot Your Android Phone or Tablet Into Safe Mode HTG Explains: Does Your Android Phone Need an Antivirus?

    Read the article

  • ListView with button and check mark?

    - by jgelderloos
    So I have looked through a lot of other answers but have not been able to get my app to work how I want it. I basically want the list view that has the text and check mark to the right, but then an addition button to the left. Right now my list view shows up but the check image is never changed. Selector: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@drawable/accept_on" /> <item android:drawable="@drawable/accept" /> </selector> Row xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:background="#EEE"> <ImageButton android:id="@+id/goToMapButton" android:src="@drawable/go_to_map" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left" /> <TextView android:id="@+id/itemName" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:textColor="#000000" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:layout_weight="1" /> <Button android:id="@+id/checkButton" android:background="@drawable/item_selector" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" /> </LinearLayout> MapAdapter: import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; public class MapAdapter extends ArrayAdapter<String>{ Context context; int layoutResourceId; String data[] = null; LayoutInflater inflater; LinearLayout layout; public MapAdapter(Context context, int layoutResourceId, String[] data) { super(context, layoutResourceId, data); this.layoutResourceId = layoutResourceId; this.context = context; this.data = data; inflater = LayoutInflater.from(context); } @Override public String getItem(int position) { return data[position]; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = new ViewHolder(); if(convertView == null) { convertView = inflater.inflate(R.layout.map_item_row, null); layout = (LinearLayout)convertView.findViewById(R.id.layout); holder.map = (ImageButton)convertView.findViewById(R.id.goToMapButton); holder.name = (TextView)convertView.findViewById(R.id.itemName); //holder.check = (Button)convertView.findViewById(R.id.checkButton); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } layout.setBackgroundColor(0x00000004); holder.name.setText(getItem(position)); return convertView; } static class ViewHolder { ImageButton map; TextView name; Button check; } }

    Read the article

  • How do I vertically align an item within a list using relative layout?

    - by Jay Askren
    I am using a list view in Android 1.5 to show a list of images and text next to the image. I am trying to vertically center the text but the text is at the top of the row instead of centered. Below is my layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/row" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dip"> <ImageView android:id="@+id/item_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="10dip" android:src="@drawable/default_image" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_alignParentBottom="true" android:layout_centerVertical="true" android:gravity="center_vertical"/> <TextView android:id="@+id/item_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/item_image" android:layout_alignParentTop="true" android:layout_alignParentBottom="true" android:layout_centerVertical="true" android:gravity="center_vertical" /> </RelativeLayout> It seems strange that I need to set alignParentTop="true" when I'm trying to vertically center the text, but if I don't the text does not even show up. What am I doing wrong?

    Read the article

  • Remove Activity as Default Launcher

    - by sixeightzero
    I set my activity as a default launcher to intercept home button clicks like so: <activity android:name=".ExampleActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> When my activity, ExampleActivity is launched, if i click the home key, I get prompted to choose. If I select make this my default and chose my activity, I am stuck In my activity as desired. The problem is, when I leave the activity, I try to remove my activity from the default launcher, but am unsuccessful. I have tried: ComponentName componentName = new ComponentName( "com.example.exampleactivity", "com.example.exampleactivity.class"); pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP); And: PackageManager pm = getActivity().getPackageManager(); ComponentName name = new ComponentName(this, "com.example.exampleactivity.class"); pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); But my designation for the home is never removed. Does anyone have a working way to fix the above? I only wan't the home button to be default for a specific activity, not my entire application. When I leave the activity, it should be removed and restored to default.

    Read the article

  • Force close error expecting irregulary

    - by user1506019
    I have problem. I created an application which loads random layour from resources and I have problem because program shows random layout and closes , sometimes after 2 times and sometimes after a dozen, and I dont know where is a problem, I tried to run it on my phone and I added in the manifest write_external_storage permission, and still the same error.Please help me, and try to resolve this problem. here is my code in : java : package ka.ka.ka; import java.util.Random; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class KAMASActivity extends Activity implements OnClickListener { Button button1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button1 = (Button) findViewById(R.id.button1) ; button1.setOnClickListener(this); } @Override public void onClick(View v) { int min = 1; int max = 6; int i1=0; Random r = new Random(); i1 = r.nextInt(max - min + 1) + min; if(i1==1){setContentView(R.layout.image1); button1 = (Button) findViewById(R.id.button1) ; button1.setOnClickListener(this);} if(i1==2){setContentView(R.layout.image2); button1 = (Button) findViewById(R.id.button1) ; button1.setOnClickListener(this);} if(i1==3){setContentView(R.layout.image3); button1 = (Button) findViewById(R.id.button1) ; button1.setOnClickListener(this);} if(i1==4){setContentView(R.layout.image4); button1 = (Button) findViewById(R.id.button1) ; button1.setOnClickListener(this);} if(i1==5){setContentView(R.layout.image5); button1 = (Button) findViewById(R.id.button1) ; button1.setOnClickListener(this);} if(i1==6){setContentView(R.layout.image6); button1 = (Button) findViewById(R.id.button1) ; button1.setOnClickListener(this); } } Android Manifest : <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ka.ka.ka" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" /> <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application android:icon="@drawable/ikona" android:label="@string/app_name" > <activity android:name=".KAMASActivity" 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> And he is logcat : 07-10 10:58:51.062: D/ddm-heap(218): Got feature list request 07-10 10:58:51.311: D/dalvikvm(218): GC freed 506 objects / 46032 bytes in 122ms 07-10 10:59:30.081: D/AndroidRuntime(218): Shutting down VM 07-10 10:59:30.081: W/dalvikvm(218): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 07-10 10:59:30.081: E/AndroidRuntime(218): Uncaught handler: thread main exiting due to uncaught exception 07-10 10:59:30.102: E/AndroidRuntime(218): java.lang.NullPointerException 07-10 10:59:30.102: E/AndroidRuntime(218): at ka.ka.ka.KAMASActivity.onClick(KAMASActivity.java:32) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.view.View.performClick(View.java:2364) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.view.View.onTouchEvent(View.java:4179) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.widget.TextView.onTouchEvent(TextView.java:6541) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.view.View.dispatchTouchEvent(View.java:3709) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 0 7-10 10:59:30.102: E/AndroidRuntime(218): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 07-10 10:59:30.102: E/AndroidRuntime(218): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow. java:1659) 07-10 10:59:30.102: E/AndroidRuntime(218): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 07-10 10:59:30.102: E/AndroidRuntime(218): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.os.Handler.dispatchMessage(Handler.java:99) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.os.Looper.loop(Looper.java:123) 07-10 10:59:30.102: E/AndroidRuntime(218): at android.app.ActivityThread.main(ActivityThread.java:4363) 07-10 10:59:30.102: E/AndroidRuntime(218): at java.lang.reflect.Method.invokeNative(Native Method) 07-10 10:59:30.102: E/AndroidRuntime(218): at java.lang.reflect.Method.invoke(Method.java:521) 07-10 10:59:30.102: E/AndroidRuntime(218): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 07-10 10:59:30.102: E/AndroidRuntime(218): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 07-10 10:59:30.102: E/AndroidRuntime(218): at dalvik.system.NativeStart.main(Native Method) 07-10 10:59:30.121: I/dalvikvm(218): threadid=7: reacting to signal 3 07-10 10:59:30.121: E/dalvikvm(218): Unable to open stack trace file '/data/anr/traces.txt': Permission denied 07-10 10:59:32.562: I/Process(218): Sending signal. PID: 218 SIG: 9

    Read the article

  • Android SQLite database gets corrupted

    - by Seu
    There are about 100 people using my Android App right now and every once and while I get a crash report to the server with this stack trace: android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621) at android.app.ActivityThread.access$2200(ActivityThread.java:126) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4595) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) at dalvik.system.NativeStart.main(Native Method) Caused by: android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed at android.database.sqlite.SQLiteQuery.native_fill_window(Native Method) at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:75) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:295) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:276) at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:171) at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:248) The result is the app crashing and all the data in the DB being lost. One thing to note is that every time I read or write to the database I get a new SQLiteDatabase and close it as soon as I'm done. I thought this would simplify things, but perhaps that's causing the problem? Is it possible this is just a SQLite bug?

    Read the article

  • android checkbox box issue

    - by raqz
    i have this check box in a alertdialog. when i try to check the state of the checkbox, the application force closes. any idea why? LayoutInflater factory = LayoutInflater.from(NewActivity.this); final View textDisplayView = factory.inflate(R.layout.nearestlocs, null); final AlertDialog.Builder newAlert = new AlertDialog.Builder(NewActivity.this); newAlert.setView(textDisplayView); final CheckBox checkBoxLab = (CheckBox) findViewById(R.id.checkboxlab); newAlert.setPositiveButton("Display on Map", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if(checkBoxLab.isChecked()){ libDisplayFlag = true; } error log 03-13 08:01:58.273: ERROR/AndroidRuntime(6188): Uncaught handler: thread main exiting due to uncaught exception 03-13 08:01:58.292: ERROR/AndroidRuntime(6188): java.lang.NullPointerException 03-13 08:01:58.292: ERROR/AndroidRuntime(6188): at com.isproj3.NewActivity$3.onClick(NewActivity.java:158) 03-13 08:01:58.292: ERROR/AndroidRuntime(6188): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158) 03-13 08:01:58.292: ERROR/AndroidRuntime(6188): at android.os.Handler.dispatchMessage(Handler.java:99) xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="horizontal" android:gravity="center" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <CheckBox android:id="@+id/checkboxlib" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Library" android:gravity="left" android:textColor="#FF0000" android:paddingBottom="5px" android:textSize="07pt" android:checked="true" /> <TextView android:id="@+id/librarytext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:paddingBottom="5px" android:textSize="8pt" /> </LinearLayout> </LinearLayout>

    Read the article

  • ImageViews in a ListView not aligned vertically [Mono for Android]

    - by shalmon
    I'm very new to developing apps to android, so bear with me. Having said that, I'm trying to make a list with a image to the left and a title and description to the right of the image. The image is downloaded from the web in the background and then set in the UI as they complete. This all works. However, the images are not aligned properly and I simply cannot understand why. I'm thinking it has something to do with the layout defined in the xml file? I tried using android:layout_alignParentLeft="true" and android:layout_gravity="left" but that got me nowhere. Then I didn't know how to proceed, even after googling every way I could think of. I'm sorry if this is very basic, but I would really appreciate some help here. Here's a pic of the situation: And here's my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget28" android:layout_width="fill_parent" android:layout_height="80px" > <ImageView android:id="@+id/imageItem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_alignParentLeft="true" > </ImageView> <LinearLayout android:id="@+id/linearText" android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:layout_marginLeft="10px" android:layout_marginTop="10px" > <TextView android:id="@+id/textTop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" > </TextView> <TextView android:id="@+id/textBottom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" > </TextView> </LinearLayout> </LinearLayout> I appreciate any help you can offer.

    Read the article

  • Android - updating a list adapter creates a NullPointException

    - by GeekedOut
    I have a ListActivity which has an adapter that crashes. Here is the code that crashes the program: Question q = new Question (); q.setQuestion( "" ); questions.add(q); adapter = new ArrayAdapter<Question>(this, R.layout.user_question_list, R.id.label, questions); Here is how I create the adapter: ArrayAdapter<Question> adapter; ArrayList<Question> questions = new ArrayList <Question>( ); and the list xml is like this: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textSize="16sp" > </TextView> and the overall Activity xml is like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/question_label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Loading your questions..." /> <ListView android:id="@android:id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+id/label" android:textSize="20px" > </ListView> <Button android:id="@+id/add_question" android:layout_height="wrap_content" android:text="Ask a Question" android:onClick="sendFeedback" android:layout_width="fill_parent"> </Button> </LinearLayout> Any idea why the code where I try to update the adapter results in the NullPointerException? Thanks!!

    Read the article

  • Building Android NDK Toolchain for x86 Android on Windows via Cygwin

    - by grrussel
    The Android SDK includes the Android NDK, which in turn contains a customised GCC based tool chain for Android on ARM processors; The question is how to build the NDK tool chain to run on Windows to target x86 Android? The tool chain is already setup to build on Windows (cygwin) targeting ARM; There are also existing pre-built (unofficial) NDKs for targeting x86, but these contain pre-built tools for x86 Linux, not Windows. The NDK contains a build-toolchain.sh script to rebuild its tool chain; the question is, what specifically needs done to get that to build a tool chain targeting Android x86?

    Read the article

  • Showing Loading screen during REST service request in android app ?

    - by sat
    Currently here is what I am following, As soon as my app is launched, I have to send a request for REST service, It will take little time , so I thought of showing loading screen, In onCreate() of my Activity , first thing will be to show loading screen(progress dialog) , And I kick off the background Activity using AsyncTask , i.e. requesting for REST service and onPostexecute() I close the dialog and then I do setContentView(myxml); and update the UI . Can this approach be improved ? Problem which I faced was , Sometimes , Garbage collector may start(due to various reasons) and my app hangs at loading screen forever , because of Garbage collector , even request for REST service is not sent and because of it some wake up call comes and rest is disaster and Force close. But sometimes even ForceClose doesnot come fast , may be because of GC. so I cannot even go back and stuck in loading screen. Only thing which I can do at that point is to come back HOME. After that If I come back to my app its still loading , so definitely this approach seems to be a bad design. Whats the right approach ?

    Read the article

  • Cross-Platform Mobile Development With Mono for Android and MonoTouch

    - by Wallym
    Many years ago, in fact pre-Java, I remember a hallway discussion about the desire to write a single application that could easily run across various platforms. At the time, we were only worried about writing applications on Windows 3.1 and Mac OS 7.x. There were many discussions about windows, user interface concepts, and specifically a rather long discussion as to whether Mac users would accept a Mac application that didn't have balloon help. Thankfully, the marketplace answered this question for us with the Windows API winning the battle.A similar set of questions is currently going on in the mobile world. Unfortunately, at this point in time, there is currently no winning API and none currently in sight. What's a developer to do? Here are some questions that developers have (and there are many more):How can mobile developers target Android and the iPhone with the same code?How can .NET developers share their code across Android, iPhone and other platforms?How can developers give applications the look and feel of the specific platform and still allow as much code as possible to be shared?Mobile devices share many common features, such as cameras, accelerometers, and address books. How can we take advantage of them in a platform independent way and still give the users the look of every other application running on their platform?In this article, we'll look at some solutions to these cross-platform and code-sharing questions between Mono for Android, MonoTouch and the .NET Framework available to developers. 

    Read the article

  • Why keyboard layout is acting weird?

    - by uzumaki
    I'm using Ubuntu 12.04. I use English (USA) and Bangla (probhat) layout. Everything regarding keyboard layout was perfect since I've installed Ubuntu about 5 months ago. Suddenly, I can't write bangla anywhere (naming folder etc.) without LibreOffice. when I'm trying to write bangla anywhere only a "square" symbol comes out for each character. Interestingly, when i'm trying to view the keyboard layout, "square" symbol is there instead of each character. Very surprising. Just take a look at the screen shot of the keyboard layout. Really very unusual issue to me.

    Read the article

  • Rhythmbox goes crazy if I change keyboard layout

    - by krokoziabla
    Not so trivial to explain but I'll try. Launch Rhythmbox Insert a CD in the CD-ROM The CD is not automatically identified (it's of a not very famous Russian band) I'm manually setting track names and... Magic, black magic! If I change the keyboard layout (RU <- EN) during editing then Rhythmbox kicks me out of the editing. So if a track name contains both Russian and English words I'm compelled to write one part, press Enter (so that the changes are not lost), change layout, click on the track name, write another part in the opposite layout. In some tricky names I have to do this several times. By the way, I use Alt+Shift to change layout. Any ideas?

    Read the article

  • Problem with the keyboard layout in Emacs (ubuntu 12.04)

    - by user61648
    I've got some problems with the keyboard layout. I have a french AZERTY keyboard. When I switch to another layout (I tested both programmer DVORAK and Greek) everything seems fine. However, in emacs, I have a more unexpected (at least for me) behavior. For example, in DVORAK, I thought to obtain: On my french Keyboard - DVORAK X - Q Alt-X - Alt-Q But I have: X - Q Alt-X - Alt-X When I press the Alt key, the layout change seems to be inactivated. I precise I didn't activated any shortcut containing the Alt key for the layout switching. Moreover, I'm not sure this behavior is restricted to Emacs, but I don't use shortcuts like Alt-... in another application. Is a such behavior normal ? And in this case, how can I use a shortcut like Alt-Q when I switch to DVORAK ?

    Read the article

  • Android: Get the X and Y coordinates of a TextView?

    - by Jep Knopz
    I am working now on a project. I have 2 draggable textView in a circle. I want to add those value inside the circle when the circle is drag over the other circle. the first option that I have is to get the X and Y of the circle, but I get it. Can anyone fix my code? Here is the Code: MainActivity public class MainActivity extends Activity { int windowwidth; int windowheight; TextView bola; TextView bola2; private float x; private float y; private android.widget.RelativeLayout.LayoutParams layoutParams; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); windowwidth = getWindowManager().getDefaultDisplay().getWidth(); windowheight = getWindowManager().getDefaultDisplay().getHeight(); bola = (TextView) findViewById(R.id.ball); bola2 = (TextView) findViewById(R.id.ball2); bola2.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub layoutParams = (RelativeLayout.LayoutParams) bola2 .getLayoutParams(); switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: int x_cord = (int) event.getRawX(); int y_cord = (int) event.getRawY(); if (x_cord > windowwidth) { x_cord = windowwidth; } if (y_cord > windowheight) { y_cord = windowheight; } layoutParams.leftMargin = x_cord - 25; layoutParams.topMargin = y_cord - 75; bola2.setLayoutParams(layoutParams); break; default: break; } return true; } }); bola.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { layoutParams = (RelativeLayout.LayoutParams) bola .getLayoutParams(); switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: int x_cord = (int) event.getRawX(); int y_cord = (int) event.getRawY(); if (x_cord > windowwidth) { x_cord = windowwidth; } if (y_cord > windowheight) { y_cord = windowheight; } layoutParams.leftMargin = x_cord - 25; layoutParams.topMargin = y_cord - 75; bola.setLayoutParams(layoutParams); break; default: break; } // TODO Auto-generated method stub return true; } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; }} Activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id= "@+id/ball" android:background="@drawable/bgshape" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" tools:context=".MainActivity" /> <TextView android:id= "@+id/ball2" android:background="@drawable/bgshape" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="2" tools:context=".MainActivity" android:layout_x="60dp" android:layout_y="20dp" /> The bgshape.xml(for the circle) <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <padding android:bottom="20dp" android:left="25dp" android:right="25dp" android:top="20dp" /> <stroke android:width="2dp" android:color="#000000" /> <solid android:color="#ffffff" /> <corners android:bottomLeftRadius="30dp" android:bottomRightRadius="30dp" android:topLeftRadius="30dp" android:topRightRadius="30dp" /> This code works well. Could anyone fix this so that I can add the value inside the circle when they hit each other?

    Read the article

  • Android: How can i access email addresses in android

    - by Maxood
    I have the following code through which i am able to retrieve phone numbers. Somehow , i am not able to retrieve email addresses by using android.provider.Contacts.People API. Any ideas? import android.app.AlertDialog; import android.app.ExpandableListActivity; import android.content.ContentUris; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.Contacts.People; import android.view.View; import android.widget.ExpandableListAdapter; import android.widget.SimpleCursorTreeAdapter; import android.widget.TextView; import android.widget.ExpandableListView.OnChildClickListener; public class ShowContacts extends ExpandableListActivity implements OnChildClickListener { private int mGroupIdColumnIndex; private String mPhoneNumberProjection[] = new String[] { People.Phones._ID, People.NUMBER // CHANGE HERE }; private ExpandableListAdapter mAdapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Query for people Cursor groupCursor = managedQuery(People.CONTENT_URI, new String[] {People._ID, People.NAME}, null, null, null); // Cache the ID column index mGroupIdColumnIndex = groupCursor.getColumnIndexOrThrow(People._ID); // Set up our adapter mAdapter = new MyExpandableListAdapter(groupCursor, this, android.R.layout.simple_expandable_list_item_1, android.R.layout.simple_expandable_list_item_1, new String[] {People.NAME}, // Name for group layouts new int[] {android.R.id.text1}, new String[] {People.NUMBER}, // AND CHANGE HERE new int[] {android.R.id.text1}); setListAdapter(mAdapter); } public class MyExpandableListAdapter extends SimpleCursorTreeAdapter { public MyExpandableListAdapter(Cursor cursor, Context context, int groupLayout, int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom, int[] childrenTo) { super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom, childrenTo); } @Override protected Cursor getChildrenCursor(Cursor groupCursor) { // Given the group, we return a cursor for all the children within that group // Return a cursor that points to this contact's phone numbers Uri.Builder builder = People.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, groupCursor.getLong(mGroupIdColumnIndex)); builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY); Uri phoneNumbersUri = builder.build(); return managedQuery(phoneNumbersUri, mPhoneNumberProjection, null, null, null); } } @Override public boolean onChildClick(android.widget.ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { AlertDialog dialog = new AlertDialog.Builder(ShowContacts.this) .setMessage(((TextView) v).getText().toString()) .setPositiveButton("OK", null).create(); dialog.show(); return true; } }

    Read the article

  • Android: Expand ListView to fill space between two items

    - by BahaiResearch.com
    I have a ListView that is sandwiched between two buttons. The entire screen is in a ScrollView <Button android:text="Take a Picture" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/btnPicture" android:layout_marginRight="3dp" android:layout_marginLeft="3dp" android:layout_marginTop="5dp" android:textSize="25dp"/> <ListView android:minWidth="25px" android:minHeight="25px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/lstPhotos" android:visibility="gone" /> <Button android:text="Location Type" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/btnLocationType" android:layout_marginRight="3dp" android:layout_marginLeft="3dp" android:layout_marginTop="5dp" android:textSize="25dp" /> As I add items to the listview in code, how can I get the listview to take up enough space to be visible. It does expand to show 1 item but after I add the second item it doesn't expand any more. You can see here after I added a second picture row to the listview, it's not visible.

    Read the article

  • Android: SlidingDrawer disappears under SurfaceView

    - by ykrasik
    Hi, I'm trying to create a SlidingDrawer with LinearLayout content over a FrameLayout. At first it all seems fine, I get my SlidingDrawer's handle at the bottom of the screen. But then, if I start dragging the handle up and the content starts showing, it gets clipped by the border rectangle of the handle. If I drag the handle all the way up the entire content eventually gets shown, however if I now drag the handle down, it will be clipped by the border rectangle of the content. Also, if the handle is all the way up, as soon as I start dragging it the whole content disappears. I can still click on where the handle should be on the screen, drag it and the content would show, but I need to guess where the handle is. What seems to be causing this is the fact that I have a SurfaceView in the xml file just before SlidingDrawer. Removing the view from the xml solves this problem, however I need this view. Here's the xml: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- Removing this DrawView from here solves the problem --> <com.package.DrawView android:id="@+id/main" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <SlidingDrawer android:id="@+id/SlidingDrawer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:allowSingleTap="true" android:animateOnClick="true" android:handle="@+id/slideHandleButton" android:content="@+id/contentLayout" android:padding="10dip"> <Button android:id="@+id/slideHandleButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/sliding_button"> </Button> <LinearLayout android:id="@+id/contentLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <Button android:id="@+id/clearButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Test"> </Button> </LinearLayout> </SlidingDrawer> </FrameLayout> Java: package com.package; import android.app.Activity; import android.os.Bundle; public class SlideTest extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } package com.package; import android.content.Context; import android.util.AttributeSet; import android.view.SurfaceView; public class DrawView extends SurfaceView { public DrawView(Context context, AttributeSet attrs) { super(context, attrs); } } Edit: I just noticed that if DrawView extends View and not SurfaceView this problem goes away. However, I'm using a dedicated drawing thread and according to the documentation (and LunarLander example) when using a dedicated drawing thread, it should draw to a SurfaceView. Any help would be greatly appreciated!

    Read the article

  • Error inflating class android.widget.CompoundButton

    - by snctln
    [Disclaimer: This has been cross posted on the Android Developers Google Group I am trying to use a CompoundButton in a project I am working on. Every time I try and use it by declaring it in my layout xml file I receive the error "01-04 12:27:46.471: ERROR/AndroidRuntime(1771): Caused by: android.view.InflateException: Binary XML file line #605: Error inflating class android.widget.CompoundButton" After fighting the error for a half an hour I decided to try a minimalistic example. I am using the latest eclipse developer tools, and targeting android 2.2 makign the minimum sdk required 2.2 (8). Here is the activity java code: package com.example.CompoundButtonExample; import android.app.Activity; import android.os.Bundle; public class CompoundButtonExampleActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } Here is the layout xml code: <?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" /> <CompoundButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> Here is the manifest xml code: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.CompoundButtonExample" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".CompoundButtonExampleActivity" 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> <uses-sdk android:minSdkVersion="8" /> </manifest> As you can see it is just the default hello world project that eclipse creates for you when you start a new Android project. It only differs in the fact that I add a "CompoundButton" to the main layout in a vertical LinearLayout. Can anyone confirm this bug? Or tell me what I am doing wrong?

    Read the article

  • Easiest way to implement RSS reader on Google Android?

    - by user291888
    Hi guys, This is my first time on stack overflow, so I apologize if this question has been asked before, but is there an easy way to implement an RSS reader on the Google Android (API 1.5)? I'm searched far and wide with the code sources I know of, and I've only found one implementation which takes 6 different classes and doesn't seem to compile on the current Android SDK's. If I end up having to write my own, I'll be sure to post it here later on. Thanks a lot.

    Read the article

  • How do I style buttons in a LinearLayout like a ListView

    - by Mannaz
    I have a vertically orientated LinearLayout with some Buttons in it: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt1" android:text="Button 1"></Button> <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt2" android:text="Button 2"></Button> <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt3" android:text="Button 3"></Button> <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/bt4" android:text="Button 4"></Button> </LinearLayout> and I want this "List" of buttons to inherit the current style for ListView items. This is my current status of the stylesheet. The CKButton style gets applied over the Activity Theme. <style name="CKButton" parent="android:style/Widget.Button"> <item name="android:textSize">21sp</item> <item name="android:layout_margin">0dip</item> <!--<item name="android:background">@drawable/button_background</item>--> <item name="android:textColor">@color/button_text_normal</item> <item name="android:padding">10dip</item> <item name="android:gravity">left|center_horizontal</item> </style> As you see I tried to draw the button background myself, but depending on the system default theme the background-color changes and therefore defining a static color is not an option. Is there a way to inherit the default ListView Row background within that buttons?

    Read the article

  • How to make android app's background image repeat.

    - by virsir
    I have set a background image in my app, but the background image is small and I want it to be repeated and filled in the whole screen. What should I do <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg" android:tileMode="repeat">

    Read the article

  • Fixed footer not displaying the bottom-most list item

    - by Mohit Deshpande
    Here is my XML layout: <?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"> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> </ListView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_alignParentBottom="true"> <EditText xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" /> <Button xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="2" /> </LinearLayout> </RelativeLayout> Which causes this problem: The listview item (outlined in red) is behind the fixed footer and cannot be used. Any solutions?

    Read the article

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