Created
May 21, 2018 13:58
-
-
Save MamdouhAlShamy/3b3056f5bd73c19aa3cce8a81615a66b to your computer and use it in GitHub Desktop.
make ListItem in RecyclerView startActivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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