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 8142709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:54:02+00:00 2026-06-06T12:54:02+00:00

A search api is returning me some meta data along with a URL eventURL.

  • 0

A search api is returning me some meta data along with a URL “eventURL”. I am placing the data in the listview, each row containing some data and a unique URL.I want when the user taps on the row in the listview,that unique URL should open in a webview.I have created a WebViewActivity for it,I am having issue with implementing the onClickListener.

MainActivity

public class MainActivity extends Activity {

//private EditText m_search_text;
private EditText m_zip;
private ListView m_search_results;
private Button m_search_btn;
private JSONArray m_results; 
private LayoutInflater m_inflater;
private InputMethodManager m_ctrl;
private Spinner m_radius;
private Spinner m_activity_selector;
public static int radius = 0;
public static String activities;



static final private int EXIT_ID = Menu.FIRST;



@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
   // m_search_text = (EditText) findViewById(R.id.search_text);
    m_zip = (EditText) findViewById(R.id.zip);
    m_search_btn = (Button) findViewById(R.id.search_button);
   // m_search_results = (ListView) findViewById(R.id.lview);
    m_search_btn .setOnClickListener(go_handler);

    m_ctrl = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    m_inflater = LayoutInflater.from(this);
    addListenerOnSpinnerItemSelection();
    addListenerOnSpinner1ItemSelection();

  m_search_results = (ListView)findViewById(R.id.lview);

}

public void addListenerOnSpinnerItemSelection() {
    m_radius = (Spinner) findViewById(R.id.spinner);
    m_radius.setOnItemSelectedListener(new CustomOnItemSelectedListener());
  }

public void addListenerOnSpinner1ItemSelection(){
    m_activity_selector = (Spinner) findViewById(R.id.spinner1);
    m_activity_selector.setOnItemSelectedListener(new ActivitySelectedListener());
    }

@Override
public boolean onCreateOptionsMenu(Menu menu){
    super.onCreateOptionsMenu(menu);

    menu.add(0, EXIT_ID, 0, R.string.exit);
    return true;
    }
@Override
public boolean onOptionsItemSelected (MenuItem item){

    switch (item.getItemId()){
    case EXIT_ID:
        finish();
        return true;

    }

    return super.onOptionsItemSelected(item);

}



OnClickListener go_handler = new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        m_ctrl.hideSoftInputFromWindow(m_zip.getWindowToken(), 0);

        //String searchText = Uri.encode(m_search_text.getText().toString());
        String zip = Uri.encode(m_zip.getText().toString());

        new SearchTask().execute("?k=Fall+Classic" + "&m=meta:channel=" + activities + "&l="+ zip + "&r=" + radius);
        // Show a toast showing the search text
        Toast.makeText(getApplicationContext(),
                getString(R.string.search_msg) + " " + 
                activities, Toast.LENGTH_LONG).show();
    }
};

private class SearchTask extends AsyncTask<String, Integer, String>
{

    ProgressDialog dialog;

        @Override
        protected void onPreExecute() {

            dialog = ProgressDialog.show(MainActivity.this,"","Please Wait...");

            super.onPreExecute();
        }

        @Override
        protected String doInBackground(String... params) {
            try {
                String result = ActiveHelper.download(params [0]);
                return result;
            } catch (ApiException e) {
                e.printStackTrace();
                Log.e("alatta", "Problem making search request");
            }
            return "";
        }
        @Override
        protected void onPostExecute(String result) {
            dialog.hide();
            try {
                JSONObject obj = new JSONObject(result);
                m_results = obj.getJSONArray("_results");
                if (m_results == null ||m_results.length() == 0)
                {
                    Toast.makeText(getApplicationContext(),
                            "No Results found for " + activities, 
                            Toast.LENGTH_LONG).show();

                }
                else
                    m_search_results.setAdapter(new JSONAdapter(getApplicationContext()));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

private class JSONAdapter extends BaseAdapter
{
    public JSONAdapter(Context c){

    }

    public int getCount() 
    {
    return  m_results.length();
        }

    public Object getItem(int arg0){
        return null;
    }

    public long getItemId(int pos){
        return pos;

    }

    public View getView(int pos, View convertView, ViewGroup parent) {
        View tv;
        TextView t;

        if (convertView == null)
            tv = m_inflater.inflate (R.layout.item, parent, false);
        else
            tv = convertView;
        try {
            /* For each entry in the ListView, we need to populate 
             * its text and timestamp */
            t = (TextView) tv.findViewById(R.id.text);
            JSONObject obj = m_results.getJSONObject(pos);

            t.setText (obj.getString("title").replaceAll("\\<.*?\\>", ""));

            t = (TextView) tv.findViewById(R.id.created_at);
            JSONObject meta = obj.getJSONObject("meta");
            t.setText ("When:" + "\t"+meta.getString("startDate")+"\n"+"Location:" +"\t" +meta.getString("location")+"\n" +"More Info:"+"\t" +meta.getString("eventURL")+"\n");


        } catch (JSONException e) {

            Log.e("alatta", e.getMessage());
        }
        return tv;
    }
}}

WebViewActivity

public class WebViewActivity extends MainActivity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("url");

    }}

Thanks.

  • 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-06-06T12:54:03+00:00Added an answer on June 6, 2026 at 12:54 pm

    You need to use OnItemClickListener:

    MainActivity implements OnItemClickListener {
    
    onCreate() {
    m_search_results.setOnItemClickListener(this);
    

    Make this method:

    onItemClick(AdapterView<?> parent, View view, int position, long id) {
    
    url = JSON.getHowever(position);
    
    //get the intent, load the url, and launch the activity
    
    }
    

    You also need to handle the intent in your WebViewActivity, but that’s beside the question

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm importing some tweets using the Search API and get the returning JSON: results:
Is there a search API for getting a short text containing the search terms
I've found a PDF file of Appstore search API, that I can use some
I've found this page about the Twitter search API and some operators : http://search.twitter.com/operators
Using Facebook Search API, I got an response like: data : [ { created_time
Is there a Google Image Search API that will return data in XML format?
I'm trying to use youtube's data api to search where the search term includes
lets say we do some search useing search api then it retuns something like
When I search the same query using the Twitter API returning JSON content and
Trends data from Twitter Search API in JSON. Grabbing the file using: $jsonurl =

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.