Android Programming Tutorials

(Romina) #1
No, Really Listening To Your Friends

synchronized private void resetClient() {
client=null;
service.removeAccount(listener);
service.registerAccount(prefs.getString("user", ""),
prefs.getString("password", ""),
listener);
}

Step #4: Display the Timeline............................................................


At this point, Patchy is fully integrated with the service and should receive


callbacks on timeline changes. However, it does not do anything with those


changes. So, we need to add something to our UI to actually display the


timeline. One easy way to do that is via a ListView and custom row layout –


that way, the timeline can be as long as we want, and it will scroll to show


all of the entries.


So, modify Patchy/res/layout/main.xml to add a ListView, as shown below:


<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1"
>
<TableRow>
<TextView android:text="Status:" />
<EditText android:id="@+id/status"
android:singleLine="false"
android:gravity="top"
android:lines="5"
android:scrollHorizontally="false"
android:maxLines="5"
android:maxWidth="200sp"
/>
</TableRow>
<Button android:id="@+id/send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Send"
/>
<ListView android:id="@+id/timeline"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</TableLayout>

188
Free download pdf