Layout not displayed properly while loading Listview dynamically?

by javame_android » Thu, 22 Apr 2010 17:48:19 GMT


Sponsored Links
 Hi,

I am trying to laod the listview dynamically. There are three
textviews inside a listview. The text to be set in the textview is
fetched from the server. All this is working fine. I am able to fetch
the text and am able to display it inside the listview.

The only problem is the position of the textview. The xml layout file
is as under :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=" http://schemas.android.com/apk/res/ 
android"
        android:id="@+id/listViewShow"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:background="@drawable/brown_bg"
    android:padding = "3dip">

    <TextView
        android:id = "@+id/txtBabbleListTitle"
                android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:textColor = "#000000"
                android:text = "Hello">
    </TextView>

    <RelativeLayout
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content">

        <TextView
                android:id = "@+id/txtBabbleDateTime"
                        android:layout_width = "wrap_content"
                        android:layout_height = "wrap_content"
                        android:layout_alignParentBottom = "true"
                        android:textColor = "#000000"
                        android:text = "Hello" >
        </TextView>
    </RelativeLayout>

    <TextView
        android:id = "@+id/txtBabbleTotalReplies"
        android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:layout_alignParentRight = "true"
                android:textColor = "#000000"
                android:text = "(7)">
    </TextView>

</RelativeLayout>

If I look at this xml layout in the eclipse layout tab then it is
displayed properly. Problem occurs only when the text is fetched
dynamically.

Can some one let me know the issue?


Thanks & Regards
Sunil

--



Layout not displayed properly while loading Listview dynamically?

by javame_android » Thu, 22 Apr 2010 21:13:04 GMT


 Hi,

It is solved now.

I was inflating the row.xml in a wrong way.


Regards
Sunil

--


Sponsored Links


Other Threads

1. Writing a Date/Time Service

I am trying to write a service which runs as background process and
invoke my task (in application) at 9am everyday.

My service is:

public class DateService extends Service {

        //expressed in milliseconds
        private final long ONCE_PER_DAY = 1000 * 60 * 60 * 24;
        private final int ONE_DAY = 1;
        private final int NINE_AM = 9;
        private final int ZERO_MINUTES = 0;

    @Override
    public void onCreate() {
        Thread thr = new Thread(null, mTask, "DateService");
        thr.start();
    }

    @Override
    public void onDestroy() {
    }


    Runnable mTask = new Runnable() {
        public void run() {
            TimerTask myTask  = new MyTask();

            //perform the task once a day at 9 a.m., starting tomorrow
morning
            Timer timer = new Timer();
            timer.scheduleAtFixedRate(myTask, getTomorrowMorning9am(),
ONCE_PER_DAY);

            // Done with our work...  stop the service!
            DateService.this.stopSelf();
        }
    };

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }


    private final IBinder mBinder = new Binder() {
        @Override
        protected boolean onTransact(int code, Parcel data, Parcel
reply,
                        int flags) throws RemoteException {
            return super.onTransact(code, data, reply, flags);
        }
    };

    private Date getTomorrowMorning9am() {
            Calendar tomorrow = new GregorianCalendar();
            tomorrow.add(Calendar.DATE, ONE_DAY);
            Calendar result = new GregorianCalendar(
              tomorrow.get(Calendar.YEAR),
              tomorrow.get(Calendar.MONTH),
              tomorrow.get(Calendar.DATE),
              NINE_AM,
              ZERO_MINUTES
            );
            return result.getTime();
    }

}

Is this the right way to write my service? How would I verify my
service?

-- 

2. JNI to access GPS HAL layer function.

Hi All,

 Is it possible to write a JNI to access GPS / Wifi / USB HAL layer
function? If possible, please post the sample code.



Thanks
Bharath

-- 

3. invoke my application at given Date/Time

4. Taking pictures

5. Yahoo API in android

6. fromHtml doesn't work for textview font size, any help?

7. help with ColorStateList