twitter - Grab Tweet string value using Fabric for android -
i working on android app , new fabric api.
i trying grab string values of tweets. can populate listactivity
tweets(code taken documentation examples), cannot figure out how access list string values or tweet ids.
when this:
log.d("", adapter.getitem(1).tostring());
or
log.d("", adapter.getitem(1));
it tells me "invalid index 1, size 0"
import android.app.listactivity; import android.content.intent; import android.content.sharedpreferences; import android.os.bundle; import android.preference.preferencemanager; import android.util.log; import com.twitter.sdk.android.tweetui.tweettimelinelistadapter; import com.twitter.sdk.android.tweetui.usertimeline; public class twitterfeed extends listactivity { intent intent = new intent(); tweettimelinelistadapter test; @override protected void oncreate(bundle savedinstancestate) { sharedpreferences pref = preferencemanager.getdefaultsharedpreferences(this); string username = pref.getstring("username", "null"); super.oncreate(savedinstancestate); final usertimeline usertimeline = new usertimeline.builder() .screenname(username).includereplies(true).includeretweets(true) .build(); final tweettimelinelistadapter adapter = new tweettimelinelistadapter.builder(this) .settimeline(usertimeline) .build(); setlistadapter(adapter); test = adapter; } @override protected void onresume(){ super.onresume(); log.d("listitem", test.getitem(1).tostring()); } }
any appreciated. ahead of time!
so after bunch of research, able grab required information. need call class. reason returning 0 because list hadn't finished loading. have block in onclick listener in custom adapter.
twitterapiclient twitterapiclient = twittercore.getinstance().getapiclient(); // can use twitter directly: twitter.getapiclient() statusesservice statusesservice = twitterapiclient.getstatusesservice(); statusesservice.show(tweetid, null, null, null, new callback<com.twitter.sdk.android.core.models.tweet>() { @override public void success(result<tweet> result) { //do result, provides tweet inside of result.data log.d("tweet data", result.data.text); } public void failure(twitterexception exception) { //do on failure } });
hope gets use out of this.
Comments
Post a Comment