title: How to make clickable part of a textview in custom list view to open new activity in android
body: <p>I have a custom listview with lazyadapter. I'm trying to make clickable part of the text view on the listview to open a new activity. But I'm stucked. </p>
  
  <p>This is in LazyAdapter (I want to say that this is not an Activity. It is just LazyAdapter class):</p>
  
  <pre><code>private Activity activity;
  private String[] urls;
  private String[] tweets;
  private String[] names;
  private static LayoutInflater inflater = null;
  public ImageLoader imageLoader;
  
  public LazyAdapter(Activity a, String[] u, String[] n, String[] t) {
      activity = a;
      urls = u;
      names = n;
      tweets = t;
      inflater = (LayoutInflater) activity
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      imageLoader = new ImageLoader(activity.getApplicationContext());
  }
  
  public int getCount() {
      return urls.length;
  }
  
  public Object getItem(int position) {
      return position;
  }
  
  public long getItemId(int position) {
      return position;
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
      View vi = convertView;
      if (convertView == null)
          vi = inflater.inflate(R.layout.list_item, null);
  
      TextView user = (TextView) vi.findViewById(R.id.textUser);
      TextView tweet = (TextView) vi.findViewById(R.id.textTweet);
      ImageView image = (ImageView) vi.findViewById(R.id.imageView);
      user.setText(names[position]);
  
      String[] checkHashtag= tweets[position].split(" ");
  
  
      SpannableStringBuilder sb = new SpannableStringBuilder();
  
  
      for(final String item: checkHashtag){
          if(item.substring(0,1).matches("#")){
              sb.append(item+" ");
  
              sb.setSpan(new ClickableSpan() {
                  @Override
                  public void onClick(View view) {
  
                      Intent intent = new Intent(null, TweetActivity.class);
                      intent.putExtra("item", item);
                      Intent.startActivity(intent);
  
                  }
              }, sb.length()-item.length(), sb.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
          } else sb.append(item+" ");
  
      }
      tweet.setText(sb);
  
  
  
  
  
  
      if (tweets[position].toLowerCase().contains("http://")
              || tweets[position].toLowerCase().contains("https://")) {
  
          String[] parts = tweets[position].split(" ");
          for (String item : parts) {
              URL url;
              try {
                  url = new URL(item);
                  Pattern pattern = Pattern.compile(url.toString());
                  Linkify.addLinks(tweet, pattern, "http://");
              } catch (MalformedURLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
          }
      }
  
  
  
  
      imageLoader.DisplayImage(urls[position], image);
      return vi;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This is how I called LazyAdapter in Tweet Activity: </p>
  
  <pre><code>    LazyAdapter adapter = new LazyAdapter(this, pic_urls, user_names, tweets);
      setListAdapter(adapter);
  </code></pre>
  
  <p>But it is not working. Some problem in startActivity(intent) part.</p>