Search Results

Search found 12175 results on 487 pages for 'android listview'.

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

  • How to set an EditText on top of a ListView ?

    - by Spredzy
    Hi everyone, I am trying to do an autocomplete version my way (logic, layout, etc...) , so I don't want to use the AutoCompleteTextView. My question is how to set an EditText on top of a ListView in a class inheriting from a ListAcvitivy. I tried two kinds of layout, none of them worked. First one : <EditText android:id="@+id/autocomplete_server" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:completionThreshold="1" android:singleLine="true"/> <ListView android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" android:layout_weight="1" android:drawSelectorOnTop="false"/> <TextView android:id="@id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FF0000" android:text="No data"/> This one only shows me the EditText but does not display the list Second one : <LinearLayout android:id="@id/android:list" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dp"> <EditText android:id="@+id/autocomplete_server" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:completionThreshold="1" android:singleLine="true"/> <ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" android:layout_weight="1" android:drawSelectorOnTop="false"/> </LinearLayout> This sample gives me a : java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eip.core/com.eip.core.Search}: java.lang.ClassCastException: android.widget.LinearLayout Does anyone have any idea bout how to implement an EditText on top of a listView ?

    Read the article

  • jenkins-maven-android when running throwing the error "android-sdk-linux/platforms" is not a directory"

    - by Sam
    I start setting up the jenkins-maven-android and i'm facing an issue when running the jenkin job. My Machine Details $uname -a Linux development2 3.0.0-12-virtual #20-Ubuntu SMP Fri Oct 7 18:19:02 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux Steps to install the Android SDK in Ubuntu https://help.ubuntu.com/community/AndroidSDK since i'm working on headless env (ssh to client machine) i used following command to install the platform tools android update sdk --no-ui download apache maven and install on http://maven.apache.org/download.html mvn -version output root@development2:/opt/android-sdk-linux/tools# mvn -version Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000) Maven home: /opt/apache-maven-3.0.4 Java version: 1.6.0_24, vendor: Sun Microsystems Inc. Java home: /usr/lib/jvm/java-6-openjdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.0.0-12-virtual", arch: "amd64", family: "unix" root@development2:/opt/android-sdk-linux/tools# ran the following two command as mention in below sudo apt-get update sudo apt-get install ia32-libs Problems with Eclipse and Android SDK http://developer.android.com/sdk/installing/index.html As error suggest i gave the path to android SDK in jenkins build config still im getting the error clean install -Dandroid.sdk.path=/opt/android-sdk-linux Can someone help me to resolve this. Thanks Error I'm Getting Waiting for Jenkins to finish collecting data mavenExecutionResult exceptions not empty message : Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project base-template: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources failed: Path "/opt/android-sdk-linux/platforms" is not a directory. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. cause : Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources failed: Path "/opt/android-sdk-linux/platforms" is not a directory. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. Stack trace : org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project base-template: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources failed: Path "/opt/android-sdk-linux/platforms" is not a directory. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239) at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158) at hudson.maven.Maven3Builder.call(Maven3Builder.java:98) at hudson.maven.Maven3Builder.call(Maven3Builder.java:64) at hudson.remoting.UserRequest.perform(UserRequest.java:118) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:326) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:679) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources failed: Path "/opt/android-sdk-linux/platforms" is not a directory. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 27 more Caused by: com.jayway.maven.plugins.android.InvalidSdkException: Path "/opt/android-sdk-linux/platforms" is not a directory. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. at com.jayway.maven.plugins.android.AndroidSdk.assertPathIsDirectory(AndroidSdk.java:125) at com.jayway.maven.plugins.android.AndroidSdk.getPlatformDirectories(AndroidSdk.java:285) at com.jayway.maven.plugins.android.AndroidSdk.findAvailablePlatforms(AndroidSdk.java:260) at com.jayway.maven.plugins.android.AndroidSdk.<init>(AndroidSdk.java:80) at com.jayway.maven.plugins.android.AbstractAndroidMojo.getAndroidSdk(AbstractAndroidMojo.java:844) at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:329) at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:102) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 28 more channel stopped Finished: FAILURE* android home Echo root@development2:~# echo $ANDROID_HOME /opt/android-sdk-linux

    Read the article

  • Listview Row Overlap Problem

    - by rgrandy
    I just updated my app and I am getting some odd complaints from people who update it. I am only getting complaints from people with non-stock android phones (phones that manufacturers have modified...HTC phones, cliq, pulse, etc), other phones like the Droid, Nexus work fine. My app (Photo Frame Deluxe) has a list in it with a Image View, Text View, View (spacer) and checkbox, all in a row. What happens on the affected phones is that the rows start overlapping and it cuts the top half of everything off. My layout code for this is below, I am pulling my hair out on this, what might I have wrong in this layout. Why does this work on some phones and not on others? Any help would be appreciated. Row Layout: <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:id="@+id/photorowIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:paddingTop="10dp" android:paddingBottom="10dp" android:paddingRight="5dp" /> <TextView android:id="@+id/photorowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" /> <View android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1"/> <CheckBox android:id="@+id/photorowCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:focusable="false" android:focusableInTouchMode="false" /> </LinearLayout> Layout Row is inserted in: <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/title1_gradient" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Select Photos to Display:" android:textSize="20sp" android:textStyle="bold" android:textColor="#FFFFFFFF" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingTop="5dp" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/folderName" android:textSize="15sp" android:textStyle="bold" android:textColor="#FFFFFFFF" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingBottom="5dp" /> <View android:layout_width="fill_parent" android:layout_height="1px" android:background="#406C6C6C"/> </LinearLayout> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="1" android:drawSelectorOnTop="false" android:paddingLeft="5dp" android:paddingRight="5dp" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="bottom"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="bottom" android:background="#FF6C6C6C" android:padding="5dp"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ok" android:text="OK"/> </LinearLayout> </LinearLayout> </LinearLayout>

    Read the article

  • Android ListView delete row button - focus issue

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

    Read the article

  • Android ListView delete row button - focus issue

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

    Read the article

  • Imageview in a listview - Height is bugged?

    - by Abdullah Gheith
    I am having a listview but i have problem i have the main.xml file, which contains a Listview: <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/gradient" android:gravity="center" android:padding="1pt"> <ListView android:id="@+id/ListView01" android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@android:color/transparent" android:cacheColorHint="#00000000"/> </LinearLayout> Then, i have a custom listview file called listview.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:background="@android:color/transparent" android:cacheColorHint="#00000000"> <TextView android:gravity="center" android:textColor="#ffffff" android:background="#0097D0" android:text="Overskrift" android:id="@+id/tvOverskrift" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" /> <ImageView android:id="@+id/ivBillede" android:scaleType="fitXY" android:padding="2px" android:gravity="fill" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/test"/> <TextView android:gravity="center" android:textColor="#ED2025" android:text="Dato" android:id="@+id/tvDato" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="normal"/> <TextView android:gravity="left" android:textColor="#000000" android:text="Indledning" android:id="@+id/tvIndledning" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="normal"/> </LinearLayout> the bitmap in the imagview i am getting is from a URL. By that code, i am getting is this: http://img585.imageshack.us/img585/5665/unavngivetv.png I am getting too much space in the height as you see

    Read the article

  • My Android ListView item layout looks terrible

    - by jnylen
    I wanted to create a layout like the CyanogenMod call log in that there is a list item and a call button on the left which gets focus separately (screenshot). Instead, I get this mess. Here's my code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:minHeight="?android:attr/listPreferredItemHeight" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="4dip" > <DontPressWithParentImageView android:id="@+id/play_icon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:paddingLeft="14dip" android:paddingRight="14dip" android:layout_alignParentRight="true" android:gravity="center_vertical" android:src="@drawable/sym_play" android:background="@drawable/play_background" /> <View android:id="@+id/divider" android:layout_width="1px" android:layout_height="fill_parent" android:layout_marginTop="5dip" android:layout_marginBottom="5dip" android:layout_toLeftOf="@id/play_icon" android:layout_marginLeft="2dip" android:background="@drawable/divider_vertical_dark" /> <TextView android:id="@+id/file_info" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="8dip" android:layout_marginTop="-10dip" android:layout_marginLeft="10dip" android:layout_alignWithParentIfMissing="true" android:singleLine="true" android:ellipsize="marquee" android:textAppearance="?android:attr/textAppearanceSmall" android:textStyle="bold" /> <TextView android:id="@+id/file_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_above="@id/file_info" android:layout_alignWithParentIfMissing="true" android:layout_marginBottom="-10dip" android:layout_marginLeft="4dip" android:textAppearance="?android:attr/textAppearanceLarge" android:singleLine="true" android:ellipsize="marquee" android:gravity="center_vertical" /> </RelativeLayout> For reference, the code I started with is here and here, and the source to DontPressWithParentImageView is here (but as you can see from my screenshot, that part is working). What am I doing wrong?

    Read the article

  • how to add a checkbox in a listview?

    - by Bugzy bug
    hello guys, i have a question, been stuck for a while, i dont know how can i add a checkbox in the list, for example if I have a list of items i want to be able to check them. my xml code is the following: <LinearLayout android:id="@+id/topLayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_centerHorizontal="true" android:layout_height="wrap_content"> </LinearLayout> <LinearLayout android:id="@+id/middleLayout" android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent"> <LinearLayout android:id="@+id/leftMiddleLayout" android:orientation="vertical" android:layout_below="@+id/topLayout" android:layout_above="@+id/bottomLayout" android:layout_width="60px" android:layout_height="wrap_content" > <ListView android:id="@+id/checkboxList" android:layout_width="fill_parent" android:layout_height="wrap_content" ></ListView> <CheckBox android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:text="test"> </CheckBox> </LinearLayout> <LinearLayout android:id="@+id/rightMiddleLayout" android:orientation="vertical" android:layout_below="@+id/topLayout" android:layout_above="@+id/bottomLayout" android:layout_width="280px" android:layout_height="wrap_content" > <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" ></ListView> <TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/bottomLayout" android:layout_alignParentBottom="true" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingBottom="5pt" > <EditText android:id="@+id/insertNewItem" android:layout_width="220px" android:layout_height="wrap_content" /> <TextView android:layout_width="10px" android:layout_height="wrap_content" /> <Button android:id="@+id/addItemButton" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="Add Item"/> </LinearLayout> if you have any ideas please let me know, its for my academic studies :(( Thank you!

    Read the article

  • How Do I make my own keyboard for an app in android

    - by Ephraim
    I am currently working on an app, that requires a keyboard in a different language (Specifically Hebrew), the problem is, that I don't know where to begin. I don't want the user to have to go onto an app store, and install a separate app that has more languages in it just to use my app, and, I only want the keyboard to be available in my app, ie, it shouldn't effect anything outside my specific app. the way I am doing it right now, is to create it as part of the main layout, and just make it visible whenever the user clicks on the Edit Text. the problem with this, is I can't get the size of it to readjust. I had originally tried using 2 different layouts (one in the res/layout folder, and one in the res/layout-lnd folder), but this caused different problems in my app, making it slower. so I am wondering 2 things, either of which should work. one: how would I create the layout for the keyboard to readjust. or Two: how would I make a keyboard correctly. here is the xml code that I am useing specifically partaining to the keyboard: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:visibility="gone" android:background="@color/puzzle_dark" android:id="@+id/hebrwKeyboardView" android:layout_width="fill_parent" android:layout_height="146dip" android:layout_gravity="right|center_vertical|center_horizontal|bottom" android:fitsSystemWindows="true" android:clipChildren="false" android:orientation="vertical" > <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="145dip" android:clipChildren="false" android:layout_gravity="center_vertical|center_horizontal|bottom" android:fitsSystemWindows="true" android:orientation="horizontal" > <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="145dip" android:clipChildren="false" android:layout_gravity="center_vertical|center_horizontal|bottom" android:fitsSystemWindows="true" android:orientation="vertical" > <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:clipChildren="false" android:orientation="horizontal" android:stretchColumns="true"> <LinearLayout android:baselineAligned="true" android:layout_width="fill_parent" android:layout_gravity="center" android:layout_height="fill_parent" android:fitsSystemWindows="true" android:clipChildren="false" android:orientation="horizontal"> <Button android:id="@+id/KoofButton" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Koof" android:layout_gravity="center" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/raishButton" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Raish" android:layout_gravity="center_horizontal" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/alephButton" android:layout_gravity="center_horizontal" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Alef" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/tetButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="35dip" android:text="@string/Tet" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/vuvButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal" android:text="@string/Vuv" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/nunSophitButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal" android:text="@string/NunSofit" android:fitsSystemWindows="true" android:gravity="fill" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/memSofitButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="35dip" android:text="@string/MemSofit" android:fitsSystemWindows="true" android:ellipsize="marquee"/> <Button android:soundEffectsEnabled="true" android:id="@+id/payButton" android:layout_width="wrap_content" android:layout_height="35dip" android:text="@string/Pay" android:fitsSystemWindows="true" android:layout_gravity="center_horizontal" android:ellipsize="marquee"/> </LinearLayout> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:clipChildren="true" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:orientation="horizontal"> <RelativeLayout android:layout_width="fill_parent" android:clipChildren="true" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center" android:gravity="bottom" android:orientation="horizontal"> <Button android:layout_alignWithParentIfMissing="true" android:soundEffectsEnabled="true" android:id="@+id/shinButton" android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Shin" android:layout_alignParentLeft="true" android:fitsSystemWindows="true" /> <Button android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:layout_toRightOf="@id/shinButton" android:id="@+id/dalidButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Dalid" android:layout_alignWithParentIfMissing="true" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/gimleButton" android:layout_toRightOf="@id/dalidButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Gimle" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/chufButton" android:layout_toRightOf="@id/gimleButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Chuf" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/ieyinButton" android:layout_toRightOf="@id/chufButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Ieyin" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/yudButton" android:layout_toRightOf="@id/ieyinButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Yud" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/chetButton" android:layout_toRightOf="@id/yudButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Chet" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/lamidButton" android:layout_toRightOf="@id/chetButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Lamid" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/chufSofitButton" android:layout_toRightOf="@id/lamidButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/ChufSofit" android:fitsSystemWindows="true" /> <Button android:layout_alignWithParentIfMissing="true" android:layout_centerHorizontal="true" android:soundEffectsEnabled="true" android:id="@+id/paySofitButton" android:layout_toRightOf="@id/chufSofitButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/PaySofit" android:fitsSystemWindows="true" /> </RelativeLayout> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:orientation="horizontal"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center" android:gravity="bottom" android:orientation="horizontal"> <Button android:soundEffectsEnabled="true" android:id="@+id/zionButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Zion" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/samichButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Samich" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/betButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Bet" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/heyButton" android:layout_width="wrap_content" android:layout_gravity="center_horizontal|center_vertical|center" android:layout_height="35dip" android:text="@string/Hey" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/nunButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Nun" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/memButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Mem" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/tzadiButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Tzadi" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/tuffButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/Tuff" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/tzadiSofitButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="@string/TzadiSofit" android:fitsSystemWindows="true" /> </LinearLayout> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center_vertical|center" android:fitsSystemWindows="true" android:orientation="horizontal"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal|center" android:gravity="bottom" android:orientation="horizontal"> <Button android:soundEffectsEnabled="true" android:id="@+id/hebrewBackButton" android:layout_width="wrap_content" android:layout_height="35dip" android:layout_gravity="right" android:fitsSystemWindows="true" android:text="&lt;--"/> <Button android:soundEffectsEnabled="true" android:id="@+id/hebrewSpaceButton" android:layout_width="150dip" android:layout_height="35dip" android:layout_gravity="center_horizontal|center_vertical|center" android:text="" android:fitsSystemWindows="true" /> <Button android:soundEffectsEnabled="true" android:id="@+id/hebrewDoneButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="Done" android:fitsSystemWindows="true" /> </LinearLayout> </TableRow> </TableLayout> </TableLayout> </FrameLayout> Here is a picture of what it looks like right now in portrait: and here is what it looks like in landscape:

    Read the article

  • Multiple screen support in android?

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

    Read the article

  • Android RelativeLayout fill_parent unexpected behavior in a ListView with varying row heights

    - by Jameel Al-Aziz
    I'm currently working on a small update to a project and I'm having an issue with Relative_Layout and fill_parent in a list view. I'm trying to insert a divider between two sections in each row, much like the divider in the call log of the default dialer. I checked out the Android source code to see how they did it, but I encountered a problem when replicating their solution. To start, here is my row item layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:padding="10dip" android:layout_height="fill_parent" android:maxHeight="64dip" android:minHeight="?android:attr/listPreferredItemHeight"> <ImageView android:id="@+id/infoimage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:src="@drawable/info_icon_big" android:layout_alignParentRight="true" android:layout_centerVertical="true"/> <View android:id="@+id/divider" android:background="@drawable/divider_vertical_dark" android:layout_marginLeft="11dip" android:layout_toLeftOf="@+id/infoimage" android:layout_width="1px" android:layout_height="fill_parent" android:layout_marginTop="5dip" android:layout_marginBottom="5dip" android:layout_marginRight="4dip"/> <TextView android:id="@+id/TextView01" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@+id/ImageView01" android:layout_toLeftOf="@+id/divider" android:gravity="left|center_vertical" android:layout_marginLeft="4dip" android:layout_marginRight="4dip"/> <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:background="@drawable/bborder" android:layout_centerVertical="true"/> </RelativeLayout> The issue I'm facing is that each row has a thumbnail of varying height (ImageView01). If I set the RelativeLayout's layout_height property to fill_parent, the divider does not scale vertically to fill the row (it just remains a 1px dot). If I set layout_height to "?android:attr/listPreferredItemHeight", the divider fills the row, but the thumbnails shrink. I've done some debugging in the getView() method of the adapter, and it seems that the divider's height is not being set properly once the row has it's proper height. Here is a portion of the getView() method: public View getView(int position, View view, ViewGroup parent) { if (view == null) { view = inflater.inflate(R.layout.tag_list_item, parent, false); } The rest of the method simply sets the appropriate text and images for the row. Also, I create the inflater object in the adapter's constructor with: inflater = LayoutInflater.from(context); Am I missing something essential? Or does fill_parent just not work with dynamic heights?

    Read the article

  • custom listview adapter getView method being called multiple times, and in no coherent order

    - by edzillion
    I have a custom list adapter: class ResultsListAdapter extends ArrayAdapter<RecordItem> { in the overridden 'getView' method I do a print to check what position is and whether it is a convertView or not: @Override public View getView(int position, View convertView, ViewGroup parent) { System.out.println("getView " + position + " " + convertView); The output of this (when the list is first displayed, no user input as yet) 04-11 16:24:05.860: INFO/System.out(681): getView 0 null 04-11 16:24:29.020: INFO/System.out(681): getView 1 android.widget.RelativeLayout@43d415d8 04-11 16:25:48.070: INFO/System.out(681): getView 2 android.widget.RelativeLayout@43d415d8 04-11 16:25:49.110: INFO/System.out(681): getView 3 android.widget.RelativeLayout@43d415d8 04-11 16:25:49.710: INFO/System.out(681): getView 0 android.widget.RelativeLayout@43d415d8 04-11 16:25:50.251: INFO/System.out(681): getView 1 null 04-11 16:26:01.300: INFO/System.out(681): getView 2 null 04-11 16:26:02.020: INFO/System.out(681): getView 3 null 04-11 16:28:28.091: INFO/System.out(681): getView 0 null 04-11 16:37:46.180: INFO/System.out(681): getView 1 android.widget.RelativeLayout@43cff8f0 04-11 16:37:47.091: INFO/System.out(681): getView 2 android.widget.RelativeLayout@43cff8f0 04-11 16:37:47.730: INFO/System.out(681): getView 3 android.widget.RelativeLayout@43cff8f0 AFAIK, though I couldn't find it stated explicitly, getView() is only called for visible rows. Since my app starts with four visible rows at least the position numbers cycling from 0-3 makes sense. But the rest is a mess: Why is getview called for each row four times? Where are these convertViews coming from when I haven't scrolled yet? I did a bit of reseach, and without getting a good answer, I did notice that people were associating this issue with layout issues. So in case, here's the layout that contains the list: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/pageDetails" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="false" /> </LinearLayout> and the layout of each individual row: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="108dp" android:padding="4dp"> <ImageView android:id="@+id/thumb" android:layout_width="120dp" android:layout_height="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginRight="8dp" android:src="@drawable/loading" /> <TextView android:id="@+id/price" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_toRightOf="@id/thumb" android:layout_alignParentBottom="true" android:singleLine="true" /> <TextView android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:paddingRight="4dp" android:singleLine="true" /> <TextView android:id="@+id/title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="17dp" android:layout_toRightOf="@id/thumb" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:paddingRight="4dp" android:layout_alignWithParentIfMissing="true" android:gravity="center" /> Thank you for your time

    Read the article

  • android app working on simulator but not on phone

    - by raqz
    i have this app that i developed and it works great on the simulator with no errors what so ever. but the moment i try to run the same on the phone for testing, the app crashes stating filenotfoundexception. it says the file /res/drawable/divider_horizontal.9.png is missing. but actually speaking, i have never referenced that file through my code. i believe its a system/os file that is unavailable. i have a custom list view, i guess its the divider there... could somebody please suggest what is wrong here. i believe this is a similar issue discussed here..but i am unable to make any sense out of it http://code.google.com/p/transdroid/issues/detail?id=14 the listview.xml layout file <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:gravity="left|center" android:layout_width="wrap_content" android:paddingBottom="5px" android:paddingTop="5px" android:paddingLeft="5px" > <ImageView android:id="@+id/linkImage" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="6dip" android:src="@drawable/icon" /> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/firstLineView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:textColor="#FFFF00" android:text="first line title"></TextView> <TextView android:id="@+id/secondLineView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="second line title" android:layout_marginLeft="10px" android:gravity="center" android:textColor="#0099CC"></TextView> </LinearLayout> </LinearLayout> the main xml file that calls the listview.xml <?xml version="1.0" encoding="UTF-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="40px"> <Button android:id="@+id/todayButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Today" android:textSize="12sp" android:gravity="center" android:layout_weight="1" /> <Button android:id="@+id/tomorrowButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Tomorrow" android:textSize="12sp" android:layout_weight="1" /> <Button android:id="@+id/WeekButton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Future" android:textSize="12sp" android:layout_weight="1" /> </LinearLayout> <LinearLayout android:id="@+id/listLayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/ListView01" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <TextView android:id="@id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="No Results" /> </LinearLayout> </LinearLayout> </FrameLayout> and the code for the same is private class EfficientAdapter extends BaseAdapter{ private LayoutInflater mInflater; private String eventTitleArray[]; private String eventDateArray[]; private String eventImageLinkArray[]; public EfficientAdapter(Context context,String[] eventTitleArray,String[] eventDateArray, String[] eventImageLinkArray){ mInflater = LayoutInflater.from(context); this.eventDateArray=eventDateArray; this.eventTitleArray=eventTitleArray; this.eventImageLinkArray =eventImageLinkArray; } public int getCount(){ //return XmlParser.todayEvents.size()-1; return this.eventDateArray.length; } public Object getItem(int position){ return position; } public long getItemId(int position){ return position; } public View getView(int position, View convertView, ViewGroup parent){ ViewHolder holder; if(convertView == null){ convertView = mInflater.inflate(R.layout.listview,null); holder = new ViewHolder(); holder.firstLine = (TextView) convertView.findViewById(R.id.firstLineView); holder.secondLine = (TextView) convertView.findViewById(R.id.secondLineView); holder.imageView = (ImageView) convertView.findViewById(R.id.linkImage); //holder.checkbox = (CheckBox) convertView.findViewById(R.id.star); holder.firstLine.setFocusable(false); holder.secondLine.setFocusable(false); holder.imageView.setFocusable(false); //holder.checkbox.setFocusable(false); convertView.setTag(holder); }else{ holder = (ViewHolder) convertView.getTag(); } Log.i(tag, "Creating the list"); holder.firstLine.setText(this.eventTitleArray[position]); holder.secondLine.setText(this.eventDateArray[position]); Bitmap bitmap; try { bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://eventur.sis.pitt.edu/images/heinz7.jpg").getContent()); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (Exception e1) { // TODO Auto-generated catch block bitmap = BitmapFactory.decodeFile("assets/heinz7.jpg");//decodeFile(getResources().getAssets().open("icon.png")); e1.printStackTrace(); } try { try{ bitmap = BitmapFactory.decodeStream((InputStream)new URL(this.eventImageLinkArray[position]).getContent());} catch(Exception e){ bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://eventur.sis.pitt.edu/images/heinz7.jpg").getContent()); } int width = 0; int height =0; int newWidth = 50; int newHeight = 40; try{ width = bitmap.getWidth(); height = bitmap.getHeight(); } catch(Exception e){ width = 50; height = 40; } float scaleWidth = ((float)newWidth)/width; float scaleHeight = ((float)newHeight)/height; Matrix mat = new Matrix(); mat.postScale(scaleWidth, scaleHeight); try{ Bitmap newBitmap = Bitmap.createBitmap(bitmap,0,0,width,height,mat,true); BitmapDrawable bmd = new BitmapDrawable(newBitmap); holder.imageView.setImageDrawable(bmd); holder.imageView.setScaleType(ScaleType.CENTER); } catch(Exception e){ } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return convertView; } class ViewHolder{ TextView firstLine; TextView secondLine; ImageView imageView; //CheckBox checkbox; } The stack trace 12-12 22:55:25.022: ERROR/AndroidRuntime(11069): Uncaught handler: thread main exiting due to uncaught exception 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): android.view.InflateException: Binary XML file line #6: Error inflating class java.lang.reflect.Constructor 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.LayoutInflater.createView(LayoutInflater.java:512) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.LayoutInflater.rInflate(LayoutInflater.java:617) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at com.eventur.MainActivity$EfficientAdapter.getView(MainActivity.java:566) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.AbsListView.obtainView(AbsListView.java:1274) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.ListView.makeAndAddView(ListView.java:1661) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.ListView.fillDown(ListView.java:610) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.ListView.fillFromTop(ListView.java:673) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.ListView.layoutChildren(ListView.java:1519) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.AbsListView.onLayout(AbsListView.java:1113) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.View.layout(View.java:6156) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.onLayout(LinearLayout.java:918) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.View.layout(View.java:6156) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.onLayout(LinearLayout.java:918) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.View.layout(View.java:6156) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.View.layout(View.java:6156) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.View.layout(View.java:6156) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.LinearLayout.onLayout(LinearLayout.java:918) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.View.layout(View.java:6156) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.View.layout(View.java:6156) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.ViewRoot.performTraversals(ViewRoot.java:950) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.ViewRoot.handleMessage(ViewRoot.java:1529) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.os.Handler.dispatchMessage(Handler.java:99) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.os.Looper.loop(Looper.java:123) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.app.ActivityThread.main(ActivityThread.java:3977) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at java.lang.reflect.Method.invokeNative(Native Method) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at java.lang.reflect.Method.invoke(Method.java:521) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at dalvik.system.NativeStart.main(Native Method) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): Caused by: java.lang.reflect.InvocationTargetException 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.ImageView.<init>(ImageView.java:128) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at java.lang.reflect.Constructor.constructNative(Native Method) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.view.LayoutInflater.createView(LayoutInflater.java:499) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): ... 42 more 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/divider_horizontal_dark.9.png from drawable resource ID #0x7f020001 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.content.res.Resources.loadDrawable(Resources.java:1643) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.content.res.TypedArray.getDrawable(TypedArray.java:548) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.widget.ImageView.<init>(ImageView.java:138) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): ... 46 more 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): Caused by: java.io.FileNotFoundException: res/drawable/divider_horizontal_dark.9.png 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.content.res.AssetManager.openNonAssetNative(Native Method) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.content.res.AssetManager.openNonAsset(AssetManager.java:417) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): at android.content.res.Resources.loadDrawable(Resources.java:1636) 12-12 22:55:25.212: ERROR/AndroidRuntime(11069): ... 48 more

    Read the article

  • ListView items not responding to tap

    - by Justin Williams
    I'm just getting my feet wet with Android and have built a UI that contains a TabHost with three tabs. Each tab is powered by its own Activity. The first Tab contains a listview with a prepopulated set of rows and is built from a custom ArrayAdapter. The problem I'm running into is that none of the ListView rows are tappable. In other words, when I tap on them there is no orange selection. If I use the scroll ball on my Nexus One it will select, but any touch gestures don't seem to be responding. All the UI is being handled using XML files with a main.xml housing the TabHost - LinearLayout - TabWidget/FrameLayout and a nearby_activity.xml file containing my ListView UI <?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:id="@+id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/nearby_no_events" /> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1.0" android:choiceMode="multipleChoice" android:divider="#d9d9d9" android:dividerHeight="1px" android:cacheColorHint="#eee" /> </LinearLayout> And the relevant code from my Activity that is set to show in the selected tab. public class NearbyActivity extends ListActivity { private ArrayList<Event> m_events = null; private EventAdapter m_adapter = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nearby_activity); getEvents(); this.m_adapter = new EventAdapter(this, R.layout.eventrow, m_events); setListAdapter(this.m_adapter); } private void getEvents() { m_events = new ArrayList<Event>(); for (int i = 0; i < 100 ; i++) { Event e = new Event(); e.setEventName("Event " + i); e.setVenueName("Staples Center"); e.setStartDate(new Date()); m_events.add(e); } } private class EventAdapter extends ArrayAdapter<Event> { private ArrayList<Event> items; public EventAdapter(Context context, int textViewResourceId, ArrayList<Event> items) { super(context, textViewResourceId, items); this.items = items; } @Override public View getView (int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.eventrow, null); } Event e = items.get(position); if (e != null) { TextView nameText = (TextView)v.findViewById(R.id.eventName); TextView venueNameText = (TextView)v.findViewById(R.id.venueName); if (nameText != null) { nameText.setText(e.getEventName()); } if(venueNameText != null) { venueNameText.setText(e.getVenueName()); } } return v; } } } My listview row's are populated by an XML file as well. <?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="?android:attr/listPreferredItemHeight" android:orientation="vertical" android:padding="4dip"> <TextView android:id="@+id/eventName" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:inputType="text" android:singleLine="true" android:ellipsize="marquee" android:textSize="18sp" android:textColor="#000" /> <TextView android:id="@+id/venueName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/eventName" android:layout_alignParentBottom="true" android:layout_marginRight="55dip" android:singleLine="true" android:ellipsize="end" android:scrollHorizontally="true" android:textSize="13sp" android:textColor="#313131" android:layout_alignWithParentIfMissing="true" android:gravity="center_vertical" /> </RelativeLayout> Thanks for any help you can offer.

    Read the article

  • Custom listview entry works in JB not in Gingerbread

    - by Andy
    I have a ListFragment with a custom ArrayAdapter where I am overiding getView() to provide a custom View for the list item. private class DirListAdaptor extends ArrayAdapter<DirItem> { @Override public View getView(int position, View convertView, ViewGroup parent) { View aView = convertView; if (aView == null) { LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // TODO: can we not access textViewResourceId? aView = vi.inflate(R.layout.dir_list_entry, parent, false); } etc... Here is the dir_list_entry.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" android:paddingRight="?android:attr/listPreferredItemPaddingRight"> <ImageView android:id="@+id/dir_list_icon" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentBottom="true" android:layout_marginRight="6dp" android:src="@drawable/ic_launcher" /> <TextView android:id="@+id/dir_list_details" android:textAppearance="?android:attr/textAppearanceListItem" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/dir_list_icon" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:singleLine="true" android:ellipsize="marquee" android:textSize="12sp" android:text="Details" /> <TextView android:id="@+id/dir_list_filename" android:textAppearance="?android:attr/textAppearanceListItem" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/dir_list_icon" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_above="@id/dir_list_details" android:layout_alignWithParentIfMissing="true" android:gravity="center_vertical" android:textSize="14sp" android:text="Filename"/> </RelativeLayout> The bizarre thing is this works fine on Android 4.1 emulator, but I get the following error on Android 2.3: 10-01 15:07:59.594: ERROR/AndroidRuntime(1003): FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout at android.view.LayoutInflater.createView(LayoutInflater.java:518) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) at android.view.LayoutInflater.inflate(LayoutInflater.java:386) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at com.eveps.evepsdroid.ui.PhotoBrowserListFragment$DirListAdaptor.getView(PhotoBrowserListFragment.java:104) at android.widget.AbsListView.obtainView(AbsListView.java:1430) at android.widget.ListView.makeAndAddView(ListView.java:1745) at android.widget.ListView.fillDown(ListView.java:670) at android.widget.ListView.fillFromTop(ListView.java:727) at android.widget.ListView.layoutChildren(ListView.java:1598) at android.widget.AbsListView.onLayout(AbsListView.java:1260) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1243) at android.widget.LinearLayout.onLayout(LinearLayout.java:1049) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.view.ViewRoot.performTraversals(ViewRoot.java:1140) at android.view.ViewRoot.handleMessage(ViewRoot.java:1859) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:415) at android.view.LayoutInflater.createView(LayoutInflater.java:505) ... 42 more Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2 at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463) at android.view.View.<init>(View.java:1957) at android.view.View.<init>(View.java:1899) at android.view.ViewGroup.<init>(ViewGroup.java:286) at android.widget.RelativeLayout.<init>(RelativeLayout.java:173) ... 45 more I'm using the Android Support library for fragment support obviously. Seems to be a problem inflating the custom list view entry, something to do with a dimension - but why does it work on JellyBean? Has something changed in this area?

    Read the article

  • How can I create a weekly calendar view for an Android Honeycomb application?

    - by BVB
    I am working on an Android (v3.0) application that has a requirement of mimicking the weekly calendar layout found on Google Calendar: The events will be based on external requests through the Google Calendar API (I already have this part working). Using the API, I can obtain a list of events for the week, with each event having a starting and and ending datetime. I would like to use this data to show the scheduled events to the application's users in a view similar to the one above. Here's what I have so far: The XML appears below: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="800dp" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Calendar Title" android:textAppearance="?android:attr/textAppearanceLarge" /> <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" > <TextView android:id="@+id/textView2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="" /> <TextView android:id="@+id/textView3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="center" android:text="Sunday" /> <TextView android:id="@+id/textView4" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="center" android:text="Monday" /> <TextView android:id="@+id/textView5" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="center" android:text="Tuesday" /> <TextView android:id="@+id/textView6" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="center" android:text="Wednesday" /> <TextView android:id="@+id/textView7" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="center" android:text="Thursday" /> <TextView android:id="@+id/textView8" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="center" android:text="Friday" /> <TextView android:id="@+id/textView9" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:gravity="center" android:text="Saturday" /> </LinearLayout> </RelativeLayout> <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="0dp" android:scrollbars="none" >" <RelativeLayout android:id="@+id/relativeLayout242" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="0dp" > <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="0dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="40dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="80dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="120dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="160dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="200dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="240dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="280dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="320dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="360dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="400dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="440dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="480dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="520dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="560dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="600dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="640dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="680dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="720dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="760dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="800dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="840dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="880dp"/> <View android:background="#aaa" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="920dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="20dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="60dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="100dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="140dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="180dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="220dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="260dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="300dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="340dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="380dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="420dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="460dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="500dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="540dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="580dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="620dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="660dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="700dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="740dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="780dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="820dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="860dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="900dp"/> <View android:background="#777" android:layout_width = "fill_parent" android:layout_height="1dp" android:layout_marginTop="940dp"/> <LinearLayout android:id="@+id/linearLayout2" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="0dp" > <RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:padding="0dp" > <View android:background="#aaa" android:layout_width = "1dp" android:layout_height="fill_parent" android:layout_alignParentRight="true"/> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="0dp" android:gravity="center" android:text="12am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="40dp" android:gravity="center" android:text="1am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="80dp" android:gravity="center" android:text="2am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="120dp" android:gravity="center" android:text="3am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="160dp" android:gravity="center" android:text="4am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="200dp" android:gravity="center" android:text="5am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="240dp" android:gravity="center" android:text="6am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="280dp" android:gravity="center" android:text="7am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="320dp" android:gravity="center" android:text="8am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="360dp" android:gravity="center" android:text="9am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="400dp" android:gravity="center" android:text="10am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="440dp" android:gravity="center" android:text="11am" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="480dp" android:gravity="center" android:text="12pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="520dp" android:gravity="center" android:text="1pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="560dp" android:gravity="center" android:text="2pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="600dp" android:gravity="center" android:text="3pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="640dp" android:gravity="center" android:text="4pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="680dp" android:gravity="center" android:text="5pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="720dp" android:gravity="center" android:text="6pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="760dp" android:gravity="center" android:text="7pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="800dp" android:gravity="center" android:text="8pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="840dp" android:gravity="center" android:text="9pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="880dp" android:gravity="center" android:text="10pm" /> <TextView android:id="@+id/textView10" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginTop="920dp" android:gravity="center|top" android:text="11pm" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="14" android:padding="0dp" > <LinearLayout android:id="@+id/linearLayout3" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:padding="0dp" > <RelativeLayout android:id="@+id/relativeLayout4" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="180dp" android:layout_marginTop="180dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="180dp" android:layout_marginTop="180dp" android:text="Some Event" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout5" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="180dp" android:layout_marginTop="280dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="180dp" android:layout_marginTop="280dp" android:text="Some Event" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout6" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="60dp" android:layout_marginTop="40dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="60dp" android:layout_marginTop="40dp" android:text="Some Event" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout7" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="90dp" android:layout_marginTop="60dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="90dp" android:layout_marginTop="60dp" android:text="Some Event" /> <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="120dp" android:layout_marginTop="340dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="120dp" android:layout_marginTop="340dp" android:text="Some Event" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout8" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="180dp" android:layout_marginTop="380dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="180dp" android:layout_marginTop="380dp" android:text="Some Event" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout9" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="180dp" android:layout_marginTop="480dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="180dp" android:layout_marginTop="480dp" android:text="Some Event" /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeLayout10" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" > <View android:background="#00f" android:layout_width = "fill_parent" android:layout_height="180dp" android:layout_marginTop="340dp"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="180dp" android:layout_marginTop="340dp" android:text="Some Event" /> </RelativeLayout> </LinearLayout> </RelativeLayout> </LinearLayout> </RelativeLayout> </ScrollView> </LinearLayout> My approach was to make 40dp equal to 1 hr of time. Thus, whenever I would like to add an event that has a duration of 1.5 hours, I will make an 60dp button that I will place at the exact location that the time begins (12am = 0dp from the top, 1pm = 40dp from the top, 2pm = 80d from the top, etc). My questions are: Is there a better way of doing this? How can I convert my XML to be stand-alone view that could be added to any Android project? (I plan on perhaps making a blog post about the end product) Thank you!

    Read the article

  • ListView item won't extend width to fill_parent

    - by slybloty
    I have a custom ViewGroup that inflates a ListView from an xml layout. The list item layout is inflated from another xml file. All of the views are set to fill_parent. The ListView fills its parent, but the ListView items don't. I've tried putting the ListView in a LinearLayout and assigning weight to it. Tried RelativeLayout as well. Also, I've built the ListView programmaticaly, without using the xml layout. Even changed the LayoutParams before adding the view to the ViewGroup. I've also taken in consideration these posts as well: Width of clickable area in ListView w/ onListItemClick, In Android, how can I set a ListView item's height and width?, Android Listview width prob. Any ideas to why the items don't extend to fill width? And how to extend them? MyViewGroup class: public class MyViewGroup extends ViewGroup { public MyViewGroup(Context context, AttributeSet attrs) { super(context, attrs); generateMyViewGroup(); } private void generateMyViewGroup() { ListView main = (ListView) View.inflate(getContext(), R.layout.layout_main, null); main.setAdapter(new MyAdapter(getContext())); this.addView(main); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { this.getChildAt(0).layout(l, t, r, b); } } ListView xml layout: <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="3dp" android:background="#77000000" android:cacheColorHint="#00000000" android:divider="#00000000" android:dividerHeight="0dp" android:drawSelectorOnTop="false" android:scrollbars="vertical" > </ListView> ListView item layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_main_category" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/mainBackground" android:gravity="fill_horizontal|center_vertical" android:orientation="vertical" > <TextView android:id="@+id/main_category" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:paddingBottom="7dp" android:paddingLeft="20dp" android:paddingRight="5dp" android:paddingTop="20dp" android:text="test" android:textColor="@color/mainCategory" android:textSize="15sp" android:textStyle="bold" /> </LinearLayout>

    Read the article

  • Why does my layout repeats in device but looks fine on emulator when an image is added in a Relative Layout?

    - by Honey H
    let me try to explain clearly with what I want here. I have a RelativeLayout that contains a header image and the content below it. Now, when i have a header image and a list view below it, the page fits the screen in the device properly, the layout does not repeat. But when I place an image below the header image, the layout repeats in the device. Meaning i could see 2 header images in the device. Some page, I could see half of the header image that is not supposed to be there (repeated header image). However, in emulator, all the pages looks fine and fit the screen nicely. I tried changing to LinearLayout, RelativeLayout inside LinearLayout, Relative Layout, it gave me the same outcome. I hope someone could tell me why this happened. Thanks. Attached is my 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" android:orientation="vertical" android:background="@drawable/bg" > <ImageView android:id="@+id/header" android:contentDescription="@string/image" android:src= "@drawable/header" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:scaleType="centerCrop"/> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:orientation="vertical" > <ImageView android:id="@+id/journal" android:layout_width="150dp" android:layout_height="150dp" android:layout_alignTop="@+id/kick" android:adjustViewBounds="true" android:contentDescription="@string/image" android:padding="10dp" android:src="@drawable/favourite_journal" /> <ImageView android:id="@+id/kick" android:layout_width="150dp" android:layout_height="150dp" android:layout_toRightOf="@+id/journal" android:layout_below="@+id/header" android:adjustViewBounds="true" android:contentDescription="@string/image" android:padding="10dp" android:src="@drawable/favourite_kick" /> <ImageView android:id="@+id/labour" android:layout_width="150dp" android:layout_height="150dp" android:layout_below="@+id/journal" android:layout_alignLeft="@+id/journal" android:adjustViewBounds="true" android:contentDescription="@string/image" android:padding="10dp" android:src="@drawable/favourite_labour" /> <ImageView android:id="@+id/share" android:layout_width="150dp" android:layout_height="150dp" android:layout_below="@+id/kick" android:layout_alignLeft="@+id/kick" android:adjustViewBounds="true" android:contentDescription="@string/image" android:padding="10dp" android:src="@drawable/favourite_share" /> </RelativeLayout> </RelativeLayout>

    Read the article

  • Contact-app like scrollinglist on android

    - by Alxandr
    I'm writing my first android app (I'm a noob at android, but decent at java). The first screen of the app consists of a huge list (about 1.5K items) of Manga-objects. The code I use is as following: main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <ListView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/android:list"></ListView> <TextView android:layout_height="fill_parent" android:layout_width="fill_parent" android:text="@string/list_no_items" android:id="@+id/android:empty"></TextView> </LinearLayout> row.xml: <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="6dip" android:src="@drawable/icon" /> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/toptext" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_vertical" /> <TextView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:id="@+id/bottomtext" android:singleLine="true" android:ellipsize="marquee" /> </LinearLayout> </LinearLayout> Then I have a adapter which basically takes a Manga-object and puts it's name in the rows toptext, and it's latest updated date in the bottomtext. However, (this might be caused by the virtualization of the unit though), the result is really slow. Scrolling the list takes forever and you can only scroll small peaces of the time. How can I make the list work like the one in the contacts-app? So that when you start scrolling a handle pops out at the right side of the screen, and when you drag it letters shows up as of how far you've scrolled (the list is sorted alphabetically), and also, is there a way I could improve the performance of the list?

    Read the article

  • Need help with Android TableLayout alignment

    - by Ben L.
    I'm trying to build a calculator layout using TableLayout, but the last two rows aren't aligning with the rest of the layout. Is there something wrong with my layout XML? What I'm trying to do would be easier to accomplish in HTML (<td> with colspan or rowspan), so should I try converting this into a WebView? Code is as follows: (Screenshot) <?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"> <EditText android:id="@+id/EditText01" android:layout_height="wrap_content" android:layout_width="fill_parent" /> <TableLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:stretchColumns="*"> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <Button android:id="@+id/Button08" android:textSize="16pt" android:text="^" android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="wrap_content" /> <Button android:id="@+id/Button09" android:text="÷" android:textSize="16pt" android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="wrap_content" /> <Button android:id="@+id/Button10" android:text="×" android:textSize="16pt" android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="wrap_content" /> <Button android:id="@+id/Button11" android:textSize="16pt" android:text="-" android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="wrap_content" /> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="2"> <LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1"> <Button android:id="@+id/Button01" android:text="7" android:textSize="16pt" android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="fill_parent" /> <Button android:layout_height="wrap_content" android:textSize="16pt" android:text="4" android:id="@+id/Button05" android:layout_weight="1" android:layout_width="fill_parent" /> </LinearLayout> <LinearLayout android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1" android:layout_width="fill_parent"> <Button android:id="@+id/Button02" android:layout_height="wrap_content" android:text="8" android:textSize="16pt" android:layout_weight="1" android:layout_width="fill_parent" /> <Button android:layout_height="wrap_content" android:textSize="16pt" android:text="5" android:id="@+id/Button06" android:layout_weight="1" android:layout_width="fill_parent" /> </LinearLayout> <LinearLayout android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1" android:layout_width="fill_parent"> <Button android:id="@+id/Button03" android:text="9" android:textSize="16pt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <Button android:textSize="16pt" android:text="6" android:id="@+id/Button07" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> <Button android:id="@+id/Button04" android:text="+" android:textSize="16pt" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" /> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="2"> <LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="2"> <LinearLayout android:layout_weight="1" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <Button android:id="@+id/Button02" android:textSize="16pt" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="1" /> <Button android:textSize="16pt" android:id="@+id/Button06" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="2" /> </LinearLayout> <Button android:id="@+id/Button01" android:layout_height="wrap_content" android:textSize="16pt" android:layout_weight="1" android:layout_width="fill_parent" android:text="0" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1"> <Button android:id="@+id/Button03" android:textSize="16pt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> <Button android:textSize="16pt" android:id="@+id/Button07" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="." /> </LinearLayout> <Button android:id="@+id/Button04" android:textSize="16pt" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:text="=" /> </TableRow> </TableLayout> </LinearLayout>

    Read the article

  • App cannot start at all in Android 2.2 (Froyo)

    - by Roland Lim
    Dear fellow Android developers & Google Engineers, My app has been running okay until the recent Froyo update. After installing the Android 2.2 SDK, I can compile my code without any errors. However, when I run it, it just force closes: Here's the log: 05-23 10:15:13.463: DEBUG/AndroidRuntime(423): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 05-23 10:15:13.463: DEBUG/AndroidRuntime(423): CheckJNI is ON 05-23 10:15:14.193: DEBUG/AndroidRuntime(423): --- registering native functions --- 05-23 10:15:15.293: DEBUG/AndroidRuntime(423): Shutting down VM 05-23 10:15:15.303: DEBUG/dalvikvm(423): Debugger has detached; object registry had 1 entries 05-23 10:15:15.333: INFO/AndroidRuntime(423): NOTE: attach of thread 'Binder Thread #3' failed 05-23 10:15:16.003: DEBUG/AndroidRuntime(431): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 05-23 10:15:16.013: DEBUG/AndroidRuntime(431): CheckJNI is ON 05-23 10:15:16.273: DEBUG/AndroidRuntime(431): --- registering native functions --- 05-23 10:15:17.392: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat= [android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.handyapps.easymoney/.EasyMoney } 05-23 10:15:17.602: DEBUG/AndroidRuntime(431): Shutting down VM 05-23 10:15:17.662: DEBUG/dalvikvm(431): Debugger has detached; object registry had 1 entries 05-23 10:15:17.742: INFO/AndroidRuntime(431): NOTE: attach of thread 'Binder Thread #3' failed 05-23 10:15:17.912: INFO/ActivityManager(59): Start proc com.handyapps.easymoney for activity com.handyapps.easymoney/.EasyMoney: pid=438 uid=10035 gids={1006, 1015} 05-23 10:15:19.032: DEBUG/AndroidRuntime(438): Shutting down VM 05-23 10:15:19.032: WARN/dalvikvm(438): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): FATAL EXCEPTION: main 05-23 10:15:19.062: ERROR/AndroidRuntime(438): java.lang.RuntimeException: Unable to instantiate application com.handyapps.easymoney.EasyMoney: java.lang.ClassCastException: com.handyapps.easymoney.EasyMoney 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread$PackageInfo.makeApplication (ActivityThread.java:649) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4232) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread.access$3000(ActivityThread.java:125) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.os.Handler.dispatchMessage(Handler.java:99) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.os.Looper.loop(Looper.java:123) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread.main(ActivityThread.java:4627) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at java.lang.reflect.Method.invokeNative(Native Method) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at java.lang.reflect.Method.invoke(Method.java:521) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:868) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at dalvik.system.NativeStart.main(Native Method) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): Caused by: java.lang.ClassCastException: com.handyapps.easymoney.EasyMoney 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.Instrumentation.newApplication(Instrumentation.java:957) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.Instrumentation.newApplication(Instrumentation.java:942) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): at android.app.ActivityThread$PackageInfo.makeApplication (ActivityThread.java:644) 05-23 10:15:19.062: ERROR/AndroidRuntime(438): ... 11 more 05-23 10:15:19.082: WARN/ActivityManager(59): Force finishing activity com.handyapps.easymoney/.EasyMoney 05-23 10:15:19.592: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{450018f0 com.handyapps.easymoney/.EasyMoney} //////////////THE ANDROID MANIFEST FILE//// <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-feature android:name="android.hardware.camera" /> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" /> <application android:icon="@drawable/icon" android:name="@string/app_name" android:label="@string/app_name" android:debuggable="false"> <activity android:name=".EasyMoney" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:launchMode="singleTask" android:clearTaskOnLaunch="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".TranList" android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".TranEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".BillReminderEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".BillReminderList" android:launchMode="singleTop" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".BudgetList" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".BudgetEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".Search" android:theme="@style/CustomDialogTheme" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".PasscodeEntry" android:theme="@style/CustomDialogTheme" android:windowSoftInputMode="stateAlwaysHidden" android:screenOrientation="portrait"/> <activity android:name=".AccountList" android:theme="@android:style/Theme.Light.NoTitleBar"> </activity> <activity android:name=".AccountEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".UserSettingsEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".CurrencySettingsEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".DisplaySettingsEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".BackupSettingsEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".CategoryList" android:theme="@android:style/Theme.Light.NoTitleBar" /> <activity android:name=".CategoryEdit" android:theme="@android:style/Theme.Light.NoTitleBar" android:windowSoftInputMode="stateAlwaysHidden"/> <activity android:name=".ExpenseByCategory" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".BalanceReport" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".MonthlyExpenseReport" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".MonthlyIncomeReport" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".MonthlyCashflowReport" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".PhotoList" android:theme="@android:style/Theme.Light.NoTitleBar" /> <activity android:name=".ExpenseByPayee" android:theme="@android:style/Theme.Light.NoTitleBar"/> <activity android:name=".ExpenseBySubCategory" android:theme="@android:style/Theme.Light.NoTitleBar"/> <service android:name="StartAlarm_Service"> <intent-filter> <action android:name="com.handyapps.easymoney.StartAlarm_Service" /> </intent-filter> </service> <service android:name=".AlarmService_Service" android:process=":remote" /> <receiver android:name="StartupIntentReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.HOME" /> </intent-filter> </receiver> <receiver android:name=".WidgetProvider" android:label="@string/widget_name"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget" /> </receiver> <receiver android:name=".WidgetProvider" android:label="@string/widget_name"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <data android:scheme="easymoney_widget" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget" /> </receiver> <receiver android:name=".WidgetProvider"> <intent-filter> <action android:name="com.handyapps.easymoney.WIDGET_CONTROL" /> <data android:scheme="easymoney_widget" /> </intent-filter> </receiver> </application> The main startup class is com.handyapps.easymoney.EasyMoney. I placed a breakpoint at the start of the onCreate() method but I discovered it didn't even reach there. Somehow, the application just couldn't be loaded in Android 2.2... but it works perfectly fine for all the previous Android versions. Been trying to find the cause for the past 2 days but am totally stumped!! Any help will be greatly appreciated!!!! Thanks!! Roland

    Read the article

  • Android text layout question: two textviews, side-by-side, with different layout alignments and weights

    - by thx1200
    I'm still a bit of an Android noob, forgive me if this is simple and I'm just not seeing it. There are two portions of text in a view that spans the entire width horizontally, but is only as high as one line of text. The left side must always be displayed in full, but should take no more horizontal space than it needs. The right side should be pushed over by the left side and fill up the remainder of the screen width. If the right side text is smaller than this width, the text should be right-aligned horizontally. If the text is greater than the width, it should scroll horizontally. The text on the right side will be updated frequently and should slide up with new text when the app tells it (explaining the TextSwitcher in the layout). I have tried two different layout styles. In both situations, I can get the left side to "push" the layout, the right side to scroll, but I can't figure out how to get the right side to right align. It is always left aligned. Here is a picture showing what is happening... http://img10.imageshack.us/img10/5599/androidlayout.png In addition (but less important), in my layout code I have android:fadingEdge="none" on the TextViews, but it still has a faded edge on the left and right side when it scrolls. Why is that? Here are the two layouts I created, which yield the results shown, but not the results I want. Using a horizontal LinearLayout... <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayoutStatusBar" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="2px" android:background="#555555" > <TextView android:id="@+id/TextViewTimer" android:textSize="18px" android:textColor="#FFFFFF" android:layout_gravity="left" android:layout_weight="0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0px" android:layout_marginRight="3px" android:text="Left Side" > </TextView> <TextSwitcher android:id="@+id/TextSwitcherDetails" android:inAnimation="@anim/push_up_in" android:outAnimation="@anim/push_up_out" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_marginLeft="3px" android:layout_marginRight="0px" > <TextView android:id="@+id/TextViewDetails1" android:textSize="18px" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="right" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" android:fadingEdge="none" android:text="Right Side 1" > </TextView> <TextView android:id="@+id/TextViewDetails2" android:textSize="18px" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="right" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" android:fadingEdge="none" android:text="Right Side 2 - This is a really long text this is long and fun and fun and long" > </TextView> </TextSwitcher> </LinearLayout> And the RelativeLayout style... <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayoutStatusBar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="2px" android:background="#555555" > <TextView android:id="@+id/TextViewTimer" android:textSize="18px" android:textColor="#FFFFFF" android:layout_gravity="left" android:layout_weight="0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="0px" android:layout_marginRight="3px" android:layout_alignParentLeft="true" android:text="Left Side" > </TextView> <TextSwitcher android:id="@+id/TextSwitcherDetails" android:inAnimation="@anim/push_up_in" android:outAnimation="@anim/push_up_out" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="3px" android:layout_marginRight="0px" android:layout_toRightOf="@+id/TextViewTimer" android:layout_alignParentRight="true" android:fadingEdge="none" android:fadingEdgeLength="0px" > <TextView android:id="@+id/TextViewDetails1" android:textSize="18px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="right" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" android:fadingEdge="none" android:fadingEdgeLength="0px" android:text="Right Side 1" > </TextView> <TextView android:id="@+id/TextViewDetails2" android:textSize="18px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="right" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:focusable="true" android:focusableInTouchMode="true" android:fadingEdge="none" android:fadingEdgeLength="0px" android:text="Right Side 2 - This is a really long text this is long and fun and fun and long" > </TextView> </TextSwitcher> </RelativeLayout> So how do I get that text on the right side to right-align. Thanks!

    Read the article

  • half or quarter black screen in android

    - by Mike McKeown
    I have an android activity that when I launch sometimes (about 1 in 4 times) it only draws quarter or half the screen before showing it. When I change the orientation or press a button the screen draws properly. I'm just using TextViews, Buttons, Fonts - no drawing or anything like that. All of my code for initialising is in the onCreate(). In this method I'm loading a text file, of about 40 lines long, and also getting a shared preference. Could this cause a delay so that it can't draw the intent? Thanks in advance if anyone has seen anything similar. EDIT - I tried commenting out the loading of the word list, but it didn't fix the problem. Here is the activity <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mainRelativeLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/blue_abstract_background" > <RelativeLayout android:id="@+id/relativeScore" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" > <TextView android:id="@+id/ScoreLabel" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:padding="10dip" android:text="SCORE:" android:textSize="18dp" /> /> <TextView android:id="@+id/ScoreText" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@id/ScoreLabel" android:padding="5dip" android:text="0" android:textSize="18dp" /> <TextView android:id="@+id/GameTimerText" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:minWidth="25dp" android:text="0" android:textSize="18dp" /> <TextView android:id="@+id/GameTimerLabel" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@id/GameTimerText" android:padding="10dip" android:text="TIMER:" android:textSize="18dp" /> /> </RelativeLayout> <RelativeLayout android:id="@+id/relativeHighScore" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/relativeScore" > <TextView android:id="@+id/HighScoreLabel" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:padding="10dip" android:text="HIGH SCORE:" android:textSize="16dp" /> <TextView android:id="@+id/HighScoreText" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/HighScoreLabel" android:padding="10dip" android:text="0" android:textSize="16dp" /> </RelativeLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:layout_below="@+id/relativeHighScore" android:orientation="vertical" > <LinearLayout android:id="@+id/linearMissing" android:layout_width="fill_parent" android:layout_height="80dp" android:layout_gravity="center" android:orientation="vertical" > <View android:layout_width="match_parent" android:layout_height="2dp" android:background="@color/yellow_text" /> <TextView android:id="@+id/MissingWordText" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="center_horizontal" android:layout_marginTop="25dp" android:text="MSSNG WRD" android:textSize="22dp" android:typeface="normal" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="2dp" android:background="@color/yellow_text" /> <TableLayout android:id="@+id/buttonsTableLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TableRow android:id="@+id/tableRow3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:paddingTop="5dp" > <Button android:id="@+id/aVowelButton" android:layout_width="66dp" android:layout_height="66dp" android:layout_gravity="center_horizontal" android:layout_marginBottom="10dp" android:layout_marginRight="5dp" android:background="@drawable/blue_vowel_button" android:text="@string/a" android:textColor="@color/yellow_text" android:textSize="30dp" /> <Button android:id="@+id/eVowelButton" android:layout_width="66dp" android:layout_height="66dp" android:layout_gravity="center_horizontal" android:layout_marginBottom="10dp" android:layout_marginRight="5dp" android:background="@drawable/blue_vowel_button" android:text="@string/e" android:textColor="@color/yellow_text" android:textSize="30dp" /> </TableRow> <TableRow android:id="@+id/tableRow4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" > <Button android:id="@+id/iVowelButton" android:layout_width="66dp" android:layout_height="66dp" android:layout_gravity="center_horizontal" android:layout_margin="5dp" android:background="@drawable/blue_vowel_buttoni" android:text="@string/i" android:textColor="@color/yellow_text" android:textSize="30dp" /> <Button android:id="@+id/oVowelButton" android:layout_width="66dp" android:layout_height="66dp" android:layout_gravity="center_horizontal" android:layout_margin="5dp" android:background="@drawable/blue_vowel_button" android:text="@string/o" android:textColor="@color/yellow_text" android:textSize="30dp" /> <Button android:id="@+id/uVowelButton" android:layout_width="66dp" android:layout_height="66dp" android:layout_gravity="center_horizontal" android:layout_margin="5dp" android:background="@drawable/blue_vowel_button" android:text="@string/u" android:textColor="@color/yellow_text" android:textSize="30dp" /> </TableRow> </TableLayout> <TextView android:id="@+id/TimeToStartText" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="24dp" /> <Button android:id="@+id/startButton" style="@style/yellowShadowText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="10dp" android:background="@drawable/blue_button_menu" android:gravity="center" android:padding="10dip" android:text="START!" android:textSize="28dp" /> </LinearLayout> </RelativeLayout> And the OnCreate() and a few methods: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_game); isNewWord = true; m_gameScore = 0; m_category = getCategoryFromExtras(); // loadWordList(m_category); initialiseTextViewField(); loadHighScoreAndDifficulty(); setFonts(); setButtons(); setStartButton(); enableDisableButtons(false); } private void loadHighScoreAndDifficulty() { //setting preferences SharedPreferences prefs = this.getSharedPreferences(m_category, Context.MODE_PRIVATE); int score = prefs.getInt(m_category, 0); //0 is the default value m_highScore = score; m_highScoreText.setText(String.valueOf(m_highScore)); prefs = this.getSharedPreferences(DIFFICULTY, Context.MODE_PRIVATE); m_difficulty = prefs.getString(DIFFICULTY, NRML_DIFFICULTY); } private void initialiseTextViewField() { m_startButton = (Button) findViewById(R.id.startButton); m_missingWordText = (TextView) findViewById(R.id.MissingWordText); m_gameScoreText = (TextView) findViewById(R.id.ScoreText); m_gameScoreLabel = (TextView) findViewById(R.id.ScoreLabel); m_gameTimerText = (TextView) findViewById(R.id.GameTimerText); m_gameTimerLabel = (TextView) findViewById(R.id.GameTimerLabel); m_timeToStartText = (TextView) findViewById(R.id.TimeToStartText); m_highScoreLabel = (TextView) findViewById(R.id.HighScoreLabel); m_highScoreText = (TextView) findViewById(R.id.HighScoreText); } private String getCategoryFromExtras() { String category = ""; Bundle extras = getIntent().getExtras(); if (extras != null) { category = extras.getString("category"); } return category; } private void enableDisableButtons(boolean enable) { Button button = (Button) findViewById(R.id.aVowelButton); button.setEnabled(enable); button = (Button) findViewById(R.id.eVowelButton); button.setEnabled(enable); button = (Button) findViewById(R.id.iVowelButton); button.setEnabled(enable); button = (Button) findViewById(R.id.oVowelButton); button.setEnabled(enable); button = (Button) findViewById(R.id.uVowelButton); button.setEnabled(enable); } private void setStartButton() { m_startButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { m_gameScore = 0; updateScore(); m_startButton.setVisibility(View.GONE); m_timeToStartText.setVisibility(View.VISIBLE); startPreTimer(); } }); }

    Read the article

  • Android Actionbar Tabs + Fragments + Service

    - by Vladimir
    So, I have 3 problems with my code: 1) I want that each tab saves its state. So that a TextView shows changed text if it was changed. 2) if I go to Tab2 then to Tab1 I can't see the content of the fragments. Only if I touch on the already selected tab, it shows me the content 3) I can't correctly connect/bind and unbind service to Fragment Text must be changed from Service. Please help, I don't know how I realize my intent. MyActivity.java package com.example.tabs; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.Fragment; import android.app.FragmentTransaction; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; public class MyActivity extends Activity { private static String ACTION_BAR_INDEX = "ACTION_BAR_INDEX"; private Tab tTab1; private Tab tTab2; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private TabListener<Tab1> tab1Listener; private TabListener<Tab2> tab2Listener; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { } } } }; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myServiceIntent = new Intent(this, MyService.class); bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); if (!isServiceRunning()) { startService(myServiceIntent); } final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); tTab1 = actionBar.newTab(); tab1Listener = new TabListener<Tab1>(this, R.id.fl_main, Tab1.class); tTab1.setTag("Tab_1"); tTab1.setText("Tab_1"); tTab1.setTabListener(tab1Listener); tTab2 = actionBar.newTab(); tab2Listener = new TabListener<Tab2>(this, R.id.fl_main, Tab2.class); tTab2.setTag("Tab_2"); tTab2.setText("Tab_2"); tTab2.setTabListener(tab2Listener); actionBar.addTab(tTab1, 0); actionBar.addTab(tTab2, 1); } @Override public void onResume() { super.onResume(); SharedPreferences sp = getPreferences(Activity.MODE_PRIVATE); int actionBarIndex = sp.getInt(ACTION_BAR_INDEX, 0); getActionBar().setSelectedNavigationItem(actionBarIndex); } protected void onSaveInstanceState(Bundle outState) { // Save the current Action Bar tab selection int actionBarIndex = getActionBar().getSelectedTab().getPosition(); SharedPreferences.Editor editor = getPreferences(Activity.MODE_PRIVATE).edit(); editor.putInt(ACTION_BAR_INDEX, actionBarIndex); editor.apply(); // Detach each of the Fragments FragmentTransaction ft = getFragmentManager().beginTransaction(); if (tab2Listener.fragment != null) { ft.detach(tab2Listener.fragment); } if (tab1Listener.fragment != null) { ft.detach(tab1Listener.fragment); } ft.commit(); super.onSaveInstanceState(outState); } protected void onRestoreInstanceState(Bundle savedInstanceState) { // Find the recreated Fragments and assign them to their associated Tab // Listeners. tab1Listener.fragment = getFragmentManager().findFragmentByTag(Tab1.class.getName()); tab2Listener.fragment = getFragmentManager().findFragmentByTag(Tab2.class.getName()); // Restore the previous Action Bar tab selection. SharedPreferences sp = getPreferences(Activity.MODE_PRIVATE); int actionBarIndex = sp.getInt(ACTION_BAR_INDEX, 0); getActionBar().setSelectedNavigationItem(actionBarIndex); super.onRestoreInstanceState(savedInstanceState); } public boolean isServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MyService.class.getName().equals(service.service.getClassName())) { return true; } } return false; } @Override protected void onDestroy() { super.onDestroy(); unbindService(myConnection); stopService(myServiceIntent); } public static class TabListener<T extends Fragment> implements ActionBar.TabListener { private Fragment fragment; private Activity activity; private Class<T> fragmentClass; private int fragmentContainer; public TabListener(Activity activity, int fragmentContainer, Class<T> fragmentClass) { this.activity = activity; this.fragmentContainer = fragmentContainer; this.fragmentClass = fragmentClass; } public void onTabReselected(Tab tab, FragmentTransaction ft) { if (fragment != null) { ft.attach(fragment); } } public void onTabSelected(Tab tab, FragmentTransaction ft) { if (fragment == null) { String fragmentName = fragmentClass.getName(); fragment = Fragment.instantiate(activity, fragmentName); ft.add(fragmentContainer, fragment, fragmentName); } else { ft.detach(fragment); } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (fragment != null) { ft.detach(fragment); } } } } MyService.java package com.example.tabs; import android.app.Service; import android.content.Intent; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; public class MyService extends Service { private final IBinder myBinder = new MyBinder(); private static Handler myServiceHandler; public IBinder onBind(Intent intent) { return myBinder; } public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); return START_STICKY; } public void sendMessage(String sText, int id) { Bundle bundle = new Bundle(); bundle.putString("Text" + id, sText); Message bundleMessage = new Message(); bundleMessage.setData(bundle); myServiceHandler.sendMessage(bundleMessage); } public class MyBinder extends Binder { public MyService getService() { return MyService.this; } public void setCallbackHandler(Handler myActivityHandler) { myServiceHandler = myActivityHandler; } public void removeCallbackHandler() { myServiceHandler = null; } } } Tab1.java package com.example.tabs; import android.app.Activity; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Tab1 extends Fragment { public static String TAG = Tab1.class.getClass().getSimpleName(); private static TextView tvText; private EditText editText; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { tvText.setText(text); } } } }; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab1, container, false); tvText = (TextView) view.findViewById(R.id.tv_tab1); editText = (EditText) view.findViewById(R.id.editText1); Button btn1 = (Button) view.findViewById(R.id.btn_change_text_1); btn1.setOnClickListener(new OnClickListener() { public void onClick(View v) { myService.sendMessage(String.valueOf(editText.getText()), 1); } }); return view; } @Override public void onAttach(Activity activity) { super.onAttach(activity); myServiceIntent = new Intent(activity, MyService.class); activity.bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); } @Override public void onDetach() { super.onDetach(); getActivity().unbindService(myConnection); } } Tab2.java package com.example.tabs; import android.app.Activity; import android.app.Fragment; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Tab2 extends Fragment { public static String TAG = Tab2.class.getClass().getSimpleName(); private static TextView tvText; private EditText editText; private static MyService.MyBinder myBinder; private static Intent myServiceIntent; private static MyService myService; private static ServiceConnection myConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder binder) { myBinder = (MyService.MyBinder) binder; myService = myBinder.getService(); myBinder.setCallbackHandler(myServiceHandler); } public void onServiceDisconnected(ComponentName name) { myService = null; myBinder = null; } }; /** Callbackhandler. */ private static Handler myServiceHandler = new Handler() { public void handleMessage(Message message) { super.handleMessage(message); Bundle bundle = message.getData(); if (bundle != null) { String text = bundle.getString("Text1", ""); if (!text.equals("")) { tvText.setText(text); } } } }; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab2, container, false); tvText = (TextView) view.findViewById(R.id.tv_tab2); editText = (EditText) view.findViewById(R.id.editText2); Button btn2 = (Button) view.findViewById(R.id.btn_change_text_2); btn2.setOnClickListener(new OnClickListener() { public void onClick(View v) { myService.sendMessage(String.valueOf(editText.getText()), 2); } }); return view; } @Override public void onAttach(Activity activity) { super.onAttach(activity); myServiceIntent = new Intent(activity, MyService.class); activity.bindService(myServiceIntent, myConnection, Context.BIND_AUTO_CREATE); } @Override public void onDetach() { super.onDetach(); getActivity().unbindService(myConnection); } } main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:orientation="vertical" > </LinearLayout> tab1.xml <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" android:layout_gravity="center" android:gravity="center" android:orientation="vertical" > <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <Button android:id="@+id/btn_change_text_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="Change text" /> <TextView android:id="@+id/tv_tab1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TAB1\nTAB1\nTAB1" /> </LinearLayout> tab2.xml <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" android:layout_gravity="center" android:gravity="center" android:orientation="vertical" > <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <Button android:id="@+id/btn_change_text_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="Change text" /> <TextView android:id="@+id/tv_tab2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:text="TAB2\nTAB2\nTAB2" /> </LinearLayout> AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tabs" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="TabsPlusService" android:theme="@android:style/Theme.Holo" > <activity android:name="com.example.tabs.MyActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="TabsPlusService" android:theme="@android:style/Theme.Holo" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name=".MyService" android:enabled="true" > </service> </application> </manifest>

    Read the article

  • Android Title bar leaving space in when application is resumed

    - by user466607
    I am using a Tab Host in my Android App. I have the Titlebar hidden. When I leave the App and resume to it, I have some strange behaviour. If I resume to a tab using a list activity with listView.setAdapter, the title bar is hidden and the space it takes up is consumed by the App. However, if I resume to any tab without the listView.setAdapter, the Titlebar is hidden, but space which was used by it is left behind. This is pushes my tabs (which are positioned at the bottom of the screen) off the screen. The space is once again consumed by my app if I then change to any other tab. I have tried to invalidate most of the obvious Views in my App without and success. Below is my tab_activity xml. many thanks <?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"> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" /> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" /> </LinearLayout> </TabHost> </LinearLayout> Here is the Manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tar.projectx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <application android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:name=".Splash" android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="SearchActivity" android:label="SearchActivity" android:screenOrientation="portrait"></activity> <activity android:name="SearchListActivity" android:label="SearchListActivity" android:screenOrientation="portrait"></activity> <activity android:name="ContactActivity" android:label="ContactActivity" android:screenOrientation="portrait"></activity> </application> </manifest> Interestingly, if I use the code below in the onResume method of my mainActivity which holds the tabhost, once the toast disappears, the view is refreshed and the space at the top is taken up by my app again. Obviously, this isn't much of a fix, but may help someone understand what is happening. @Override protected void onResume() { super.onResume(); Toast.makeText(this, "Welcome Back", Toast.LENGTH_LONG).show(); }

    Read the article

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