Reputation: 43
Alright so before you go and start stating, go look around as your title matches many questions asked here. And in that case, you're correct, but... Every single thing I've tried on these asked questions didn't help me at all.
So I'm actually trying to build an RssFeed application for Android devices (Still Learning). My problem comes in the MainActivity, mind you. All my classes, xmls, and other content are properly coded with no issues or errors. People are saying that you should get rid of the imports that contain "android.r" and I've looked throught and haven't found any imports that contain the said quotation.
My MainActivity code:
package com.ascendapps.licknriff;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.ascendapps.licknriff.R;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
RssReader rssReader = new RssReader("http://www.licknriff.com/feed/");
ListView Items = (ListView)findViewById(R.id.listView1);
// create a list adapter
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this.android.R.layout.simple_list_item_1, RssReader.getItems());
// --
Items.setAdapter(adapter);
// --
Items.setOnItemClickListener(new ListListener(RssReader.getItems(), this)); }catch (Exception e){
Log.e("SimpleRssReader", e.getMessage());
}
}
}
Upvotes: 2
Views: 201
Reputation: 29642
I think you have typo error. While writing code, you simply type .
( dot ) instead of ',' ( comma ). Just replace .
with ,
after this
like below,
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this, android.R.layout.simple_list_item_1, RssReader.getItems());
Upvotes: 1
Reputation: 43023
Replace
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this.android.R.layout.simple_list_item_1, RssReader.getItems());
with
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this, android.R.layout.simple_list_item_1, RssReader.getItems());
android
is the namespace of the Android R
class. It doesn't belong to your activity class.
The first parameter is of Context
type, so you activity is a suitable parameter as it inherits from Context
.
Upvotes: 4
Reputation: 201447
You have a full-stop, but you need a comma, after this
here -
// ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(
// this.android.R.layout.simple_list_item_1, RssReader.getItems());
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(
this, android.R.layout.simple_list_item_1, RssReader.getItems());
Upvotes: 1
Reputation: 4306
Change this:
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this.android.R.layout.simple_list_item_1, RssReader.getItems());
to this:
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this, android.R.layout.simple_list_item_1, RssReader.getItems());
this
should be passed as context in constructor of ArrayAdapter class.
Upvotes: 3