Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4272220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:32:53+00:00 2026-05-21T07:32:53+00:00

What I am trying to do is load a URL in a webView in

  • 0

What I am trying to do is load a URL in a webView in the main activity from a populated listView item. I am not sure how to do this and I am learning step by step, working my way to eventually adapt this to populating the listView with a dataBase once I learn this step (in this question).

The getURL variable needs to be used to load the link into mWebView in the .main activity when the list item object is clicked. (make sense??)
Thanx for your help!!

Below is what I have so far:

the listView activity (ACList.java):

public class ACList extends Activity 
{
    @Override
    public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.ac_list);

    ArrayList<SearchResult> searchResults = GetSearchResults();

    final ListView lv1 = (ListView) findViewById(R.id.listItems);
    lv1.setAdapter(new MyCustomBaseAdapter(this, searchResults));

    lv1.setOnItemClickListener(new OnItemClickListener() 
    {
         public void onItemClick(AdapterView<?> a, View v, int position, long id) 
         { 
              Object o = lv1.getItemAtPosition(position);
              SearchResult fullObject = (SearchResult)o;
              Toast.makeText(ACList.this, "You have chosen: " + " " + fullObject.getLabel(), Toast.LENGTH_LONG).show();
              /** -- Here is the Class I intend to start with the specified URL to the selected item
              Intent i = new Intent(ACList.this, main.class);
              i.putExtra("url", fullObject.getURL());
              startActivity(i);
              **/
         }  
    });

}

    private ArrayList<SearchResult> GetSearchResults()
    {
         ArrayList<SearchResult> results = new ArrayList<SearchResult>();

         SearchResult sr1 = new SearchResult();
         sr1.setLabel("The Lable");
         sr1.setListTitle("This is the Title");
         sr1.setCaption("This is what its about");
         sr1.setURL("http://www.somesite.com/index.html");
         results.add(sr1);
    }
}

This is my Adapter (MyCustomBaseAdapter):

public class MyCustomBaseAdapter extends BaseAdapter {
 private static ArrayList<SearchResult> searchArrayList;

 private LayoutInflater mInflater;

 public MyCustomBaseAdapter(Context context, ArrayList<SearchResult> results) {
  searchArrayList = results;
  mInflater = LayoutInflater.from(context);
 }

 public int getCount() {
  return searchArrayList.size();
 }

 public Object getItem(int position) {
  return searchArrayList.get(position);
 }

 public long getItemId(int position) {
  return position;
 }

 public View getView(int position, View convertView, ViewGroup parent) {
  ViewHolder holder;
  if (convertView == null) {
   convertView = mInflater.inflate(R.layout.list_item, null);
   holder = new ViewHolder();
   holder.txtLabel = (TextView) convertView.findViewById(R.id.label);
   holder.txtListTitle = (TextView) convertView.findViewById(R.id.listTitle);
   holder.txtCaption = (TextView) convertView.findViewById(R.id.caption);

   convertView.setTag(holder);
  } else {
   holder = (ViewHolder) convertView.getTag();
  }

  holder.txtLabel.setText(searchArrayList.get(position).getLabel());
  holder.txtListTitle.setText(searchArrayList.get(position).getListTitle());
  holder.txtCaption.setText(searchArrayList.get(position).getCaption());

  return convertView;
 }

 static class ViewHolder {
  TextView txtLabel;
  TextView txtListTitle;
  TextView txtCaption;
 }
}

…and my SearchResult.java:

public class SearchResult 
{
 private String label = "";
 private String listTitle = "";
 private String caption = "";
 private String listURL = "";

 public void setLabel(String label) {
  this.label = label;
 }

 public String getLabel() {
  return label;
 }

 public void setListTitle(String listTitle) {
  this.listTitle = listTitle;
 }

 public String getListTitle() {
  return listTitle;
 }

 public void setCaption(String caption) {
  this.caption = caption;
 }

 public String getCaption() {
  return caption;
 }

 public void setURL(String listURL) {
      this.listURL = listURL;
     }

     public String getURL() {
      return listURL;
     }   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:32:54+00:00Added an answer on May 21, 2026 at 7:32 am

    I figured out what the problem was; I was missing a string variable in my .main activity that links up w/the item in the listView activity. See below (First line).

    Bonus – For whoever has use for it: The onProgressChanged in the webChromeClient shown below has a pre-loader that fires every time a new URL is loaded into it. Just add the “pd” variable below the setContent(R.layout.myActivity) and copy & past the mWebView.setWebClient block in2 your activity as well that has the webView. Enjoy!

    ....
    setContentView(R.layout.main);
    
        activityTitle = (TextView) findViewById(R.id.app_name);
        activityIcon  = (ImageButton) findViewById(R.id.icon);
        pd = ProgressDialog.show(this, "", "Initializing....", true);
    
    .....
    
    String url =getIntent().getStringExtra("url");// <-- Gets the URL that is passed from the list activity
        mWebView= (WebView) findViewById(R.id.webView1);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl(url);
    
        mWebView.setWebChromeClient(new WebChromeClient()
        {
            public void onProgressChanged(WebView view, int progress)
            {
                activityTitle.setText("Loading....");
                activity.setProgress(progress * 100);
                pd.show();
    
                if(progress == 100)
                    pd.dismiss();
                    activityTitle.setText(" flyDroid ELUA");
                    activityIcon.setImageResource(R.drawable.ic_menu_icon); 
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set the URL for a WebView from the layout main.xml. By
I am trying to setup a application to load URL in Webview and then
I'm receiving an error when trying to load a URL in a WebView. What
I am trying to load URL inside a WebViewClient as below: webview.setWebViewClient(new WebViewClient() {
I have an array of URL Links that I'm trying to load into a
While trying to load a Bitmap onto a SWFLoader the Event.COMPLETE event is not
When trying to load Microsoft.Xna.Framework.dll from any project, it throws a FileNotFoundException. The specified
I am am trying to load a SQL table from a flat file. The
I am trying to load UIImage object from NSData , and the sample code
I'm trying to load the parsed html data from an rss feed using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.