我已经在我的CustomTweetTimelineListAdapter类上覆盖了OnClikListener以及示例并且工作正常但是当推文包含一个url时,未检测到链接上的点击并且调用适配器OnClicklistener操作,它可以进行单击链接打开URL而不是使适配器OnClickListener操作?
package client.tclient.com.client;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import com.twitter.sdk.android.core.models.Tweet;
import com.twitter.sdk.android.tweetui.Timeline;
import com.twitter.sdk.android.tweetui.TweetTimelineListAdapter;
/**
* Created by alvaro on 13/06/16.
*/
public class CustomTweetTimelineListAdapter extends TweetTimelineListAdapter implements Adapter{
private Context context;
/**
* Constructs a TweetTimelineListAdapter for the given Tweet Timeline.
*
* @param context the context for row views.
* @param timeline a Timeline<Tweet> providing access to Tweet data items.
* @throws IllegalArgumentException if timeline is null
*/
public CustomTweetTimelineListAdapter(Context context, Timeline<Tweet> timeline) {
super(context, timeline);
this.context = context;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
//disable subviews
if(view instanceof ViewGroup){
disableViewAndSubViews((ViewGroup) view);
}
//enable root view and attach custom listener
view.setEnabled(true);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Long tweetId = getItemId(position);
Intent intent = new Intent(context,TweetActivity.class);
intent.putExtra("TWEET_ID", tweetId);
context.startActivity(intent);
}
});
return view;
}
private void disableViewAndSubViews(ViewGroup layout) {
layout.setEnabled(false);
for (int i = 0; i < layout.getChildCount(); i++) {
View child = layout.getChildAt(i);
if (child instanceof ViewGroup) {
disableViewAndSubViews((ViewGroup) child);
} else {
child.setEnabled(false);
child.setClickable(false);
child.setLongClickable(false);
}
}
}
}
答案 0 :(得分:0)
您的视图应该包含链接的引用,假设它是TextView
并为该子视图定义一个监听器。