It was marked as a duplicate by someone but it's quite different since its "duplicate" deals with URL when clicking.
So what I would want is when I launch the app I'm trying to make is it would generate random article headlines from a list of headlines I made. However, instead of doing that, it displays some random stuff containing a directory I think of my activity. I was able to do it in another app I made, got the same logic and now it won't work for this specific app.
Here's the portion of my code where I try to generate a random headline:
private void randomArticle() {
String mArticleRandom[] = {"Anton, tuli na!", "Karlo, nanganak na!", "La Salle Wins Shell ECO", "Andreev, sinagot na ni Janella!", "Norman, ang bagong Hashtag!"};
//String mStatusRandom[] = {"So puhrung like", "Patayin ko kayong lahat!", "Pagod na ako maging single :(", "I like Andreev", "Hina ng soul ko"};
for (int i = 3; i > 0; i--) {
Random post = new Random();
int article = post.nextInt(5);
//int message = post.nextInt(5);
mArticleList.add(new Article(mArticleRandom[article]));
}
return;
}
mAdapter = new ArrayAdapter<Article>(this, android.R.layout.simple_list_item_1, mArticleList);
ListView lstArticles = (ListView) findViewById(R.id.lst_article);
lstArticles.setAdapter(mAdapter);
lstArticles.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent launchIntent = new Intent(MainActivity.this, ArticleContentActivity.class);
Article article = mArticleList.get(position);
// String targetAuthorStr = article.getAuthor();
startActivity(launchIntent);
return;
}
}
);
And here is what it displays: