2012-01-22 32 views
2

显示状态时,让这些错误,当我运行Android应用程序:误差twitter4j

,而不是领的状态即时得到一个地位,说:“JSON例外”。 我也在elogcat中得到这些错误。 E/Twitter(468):检索推文时出错 01-22 15:39:09.783:E/Twitter(468):404:请求的URI无效或资源请求,如用户,不存在。 01-22 15:39:09.783:E/Twitter(468):{“error”:“Not found”,“request”:“/ 1/null/lists/0/statuses.json?page = 1”}

此代码运行良好。但是,然后我把图标放在我的列表视图(菜单显示状态之前...)。我在这里得到的错误:

任何想法?

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 

    Activity activity = (Activity) getContext(); 
    LayoutInflater inflater = activity.getLayoutInflater(); 

    // Inflate the views from XML 
    View rowView = inflater.inflate(R.layout.image_text_layout, null); 
    JSONObject jsonImageText = getItem(position); 

ImageView imageview =(ImageView)rowView.findViewById(R.id.last_build_stat); 
try { 
    String date = (String)jsonImageText.get("tweetDate"); 
    String avatar = (String)jsonImageText.get("avatar"); 
    imageview.setImageBitmap(getBitmap(avatar)); 
} catch (JSONException e) { 

    e.printStackTrace(); 
} 


    // Set the text on the TextView 
    TextView textView = (TextView) rowView.findViewById(R.id.job_text); 


    try { 

     String tweet = (String)jsonImageText.get("tweet"); 

     String auth = (String)jsonImageText.get("author"); 

     //String date = (String)jsonImageText.get("tweetDate"); 

     if (date.length()>0){ 

      String latest = tweet + "<br><br><i>" + auth + " - " + date + "</i>"; 
      //String latest = tweet; 
      textView.setText(Html.fromHtml(latest)); 
     } else { 

      textView.setText(Html.fromHtml(tweet) + "\n" + Html.fromHtml(auth)); 
     } 


    } catch (JSONException e) { 

     textView.setText("JSON Exception"); 
    } 

回答

0
URI requested is invalid or the resource requested, such as a user, does not exists. 01-22 15:39:09.783: E/Twitter(468): {"error":"Not found","request":"/1/null/lists/0/statuses.json?page=1"} 

从这个消息很明显,调用Twitter的API失败。我会建议在调用Twitter API之前添加一些打印语句,并打印出您正在尝试的URL。

0

感谢您了解我的菜单关键字需要用大写字母。