Skip to content

Instantly share code, notes, and snippets.

@MamdouhAlShamy
Created May 21, 2018 13:58
Show Gist options
  • Save MamdouhAlShamy/3b3056f5bd73c19aa3cce8a81615a66b to your computer and use it in GitHub Desktop.
Save MamdouhAlShamy/3b3056f5bd73c19aa3cce8a81615a66b to your computer and use it in GitHub Desktop.
make ListItem in RecyclerView startActivity
public class StoryViewHolder extends RecyclerView.ViewHolder {
public final TextView titleTextView;
public final TextView sectionTextView;
public String url = "";
public StoryViewHolder(View itemView, final Context context) {
super(itemView);
titleTextView = itemView.findViewById(R.id.title_text_view);
sectionTextView = itemView.findViewById(R.id.section_text_view);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Uri storyUri = Uri.parse(url);
Intent websiteIntent = new Intent(Intent.ACTION_VIEW, storyUri);
context.startActivity(websiteIntent);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment