Now have a working TweetsListActivity

Needs a bit of tweaking, but functionality is mostly there.
master
DjBushido 2014-04-12 13:35:08 -04:00
parent e23b4bd798
commit 8d4d50c4a9
4 changed files with 45 additions and 41 deletions

View File

@ -1,57 +1,49 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1" android:id="@+id/RelativeLayout1"
android:layout_width="30dp" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="fill_parent" >
android:columnCount="2"
android:orientation="vertical" >
<ImageView <ImageView
android:id="@+id/imgProfileImage" android:id="@+id/imgProfileImage"
android:layout_width="wrap_content" android:layout_width="50dp"
android:layout_height="wrap_content" android:layout_height="50dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" /> android:src="@drawable/ic_launcher" />
<LinearLayout <TextView
android:id="@+id/txtTweetText"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/imageView1" android:layout_toRightOf="@+id/imgProfileImage"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:orientation="vertical" > android:text="TextView" />
<TextView <TextView
android:id="@+id/txtTweetText" android:id="@+id/txtTweetInfo"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" /> android:layout_alignLeft="@+id/txtTweetText"
android:layout_below="@+id/txtTweetText"
android:layout_toLeftOf="@+id/imgIsRetweet"
android:text="TextView" />
<LinearLayout <ImageButton
android:layout_width="match_parent" android:id="@+id/ibtnSaveTweet"
android:layout_height="wrap_content" > android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="@+id/txtTweetText"
android:onClick="onSaveTweet"
android:src="@drawable/add_bookmark" />
<TextView <ImageView
android:id="@+id/txtTweetInfo" android:id="@+id/imgIsRetweet"
android:layout_width="wrap_content" android:layout_width="50dp"
android:layout_height="wrap_content" android:layout_height="50dp"
android:text="TextView" /> android:layout_alignTop="@+id/ibtnSaveTweet"
android:layout_toLeftOf="@+id/ibtnSaveTweet"
<ImageView android:src="@drawable/not_retweeted" />
android:id="@+id/imgIsRetweet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/not_retweeted" />
<ImageButton
android:id="@+id/ibtnSaveTweet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onSaveTweet"
android:src="@drawable/add_bookmark" />
</LinearLayout>
</LinearLayout>
</RelativeLayout> </RelativeLayout>

5
HW5/res/values/ids.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="TWEET_TAG_KEY" type="id"/>
</resources>

View File

@ -27,6 +27,8 @@ public class TweetListAdapter extends ArrayAdapter<Tweet> {
public TweetListAdapter(Activity activity, Tweet[] tweets) { public TweetListAdapter(Activity activity, Tweet[] tweets) {
super(activity, R.layout.tweet_list, tweets); super(activity, R.layout.tweet_list, tweets);
this.tweets = tweets;
this.activity = activity;
} }
@Override @Override
@ -47,7 +49,7 @@ public class TweetListAdapter extends ArrayAdapter<Tweet> {
tv.ibtnSaveTweet = (ImageButton) rowView.findViewById(R.id.ibtnSaveTweet); tv.ibtnSaveTweet = (ImageButton) rowView.findViewById(R.id.ibtnSaveTweet);
rowView.setTag(tv); rowView.setTag(tv);
rowView.setTag(TWEET_TAG_KEY, tweet); rowView.setTag(R.id.TWEET_TAG_KEY, tweet);
} else { } else {
tv = (TweetView) rowView.getTag(); tv = (TweetView) rowView.getTag();
} }

View File

@ -1,5 +1,6 @@
package edu.uncc.itcs4180.hw5; package edu.uncc.itcs4180.hw5;
import edu.uncc.itcs4180.hw5.twitter.Tweet;
import edu.uncc.itcs4180.hw5.twitter.TweetList; import edu.uncc.itcs4180.hw5.twitter.TweetList;
import edu.uncc.itcs4180.hw5.twitter.TwitterClient; import edu.uncc.itcs4180.hw5.twitter.TwitterClient;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -8,6 +9,8 @@ import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.widget.ListAdapter;
import android.widget.ListView;
public class TweetsListActivity extends Activity { public class TweetsListActivity extends Activity {
@ -47,7 +50,9 @@ public class TweetsListActivity extends Activity {
} }
private void displayTweets(TweetList list) { private void displayTweets(TweetList list) {
ListView lv = (ListView)findViewById(R.id.listTweetList);
ListAdapter la = new TweetListAdapter(this, list.toArray(new Tweet[list.size()]));
lv.setAdapter(la);
} }
} }