user3662124 user3662124 - 1 year ago 221
JSON Question

How to implement search on a mysql database using Android App?

Basically, I am developing an online library management system. I have successfully displayed the whole database as a listView using PHP, JSON and Async Task. Now I need to search that listView and and display the selected item's detail in a new Activity.

Answer Source

You can try creating your new activity with a WebView that opens your PHP url with a query string dictating your search. This would be a start.

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

    Intent intent = getIntent();
    String stringPassed = intent.getExtras().getString("searchParam");

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl("http://www.yoursite.com/search/?string="+stringPassed);

}

Your listView will have to pass strings to your webView activity in order to dynamically generate your query string, which is subsequently used to generate your search parameters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download