0

I am using ListView to collect and show History of where people have been to in my WebView. I have tried to find some answers but many of the answers involve extending ListView, which I can't do as I already have an extension. I am starting to get lost and confused. I would appreciate some direction to head towards next.

the getListView cannot be resolved.

Button btn5 = (Button) findViewById(R.id.historyBtn); btn5.setOnClickListener(new View.OnClickListener()

    {
        WebView webView = (WebView) findViewById(R.id.WebviewScreen);


        public void onClick(View v) {

            setContentView(R.layout.histlist);

                WebBackForwardList currentList = webView.copyBackForwardList();
                int currentSize = currentList.getSize();
                for(int i = 0; i < currentSize; ++i)
                {
                    WebHistoryItem item = currentList.getItemAtIndex(i);
                    String url = item.getUrl();
                    String[] newlist = {url};
                    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getListView().getContext, android.R.layout.simple_list_item_1, currentList);
                    getListView().setAdapter(adapter);
Jabes
  • 1
  • 4
  • `getListView()` is a method in `ListActivity` and `ListFragment`, so if you're following an example, they are likely using one of those. Unless you've implemented your own `getListView()`, that method won't be there in other types of `Activity` or `Fragment` classes. – Mike M. Oct 22 '17 at 02:09
  • Ok, so what's the best way to deal with this if I am extending my class with AppCompactActivity? is it something like ListView() = new ListView? – Jabes Oct 22 '17 at 02:12
  • Provided you have a `ListView` in your layout, you can just find it yourself, like you did the `Button` and `WebView`; e.g., `ListView list = (ListView) findViewById(R.id.my_list_id);`. – Mike M. Oct 22 '17 at 02:16

0 Answers0