Android Open Source - android-animeinfo Search Activity

From Project

Back to project page android-animeinfo.


The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project android-animeinfo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* w  ww  .  j  av  a 2 s. c o m*/
import java.util.Collection;
import java.util.Currency;

import org.json.JSONException;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class SearchActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        listView().setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view, int position,
          long id) {
        SearchResultsAdapter adapter = (SearchResultsAdapter)parent.getAdapter();
        AnimeSummary result = adapter.getItem(position);
        Intent intent = new Intent(SearchActivity.this, DetailsActivity.class);
        intent.putExtra("id", result.getId());
    public void search(View view)
      try {
      Collection<AnimeSummary> results = AnimeSummary.findResults(getQuery());
          listView().setAdapter(new SearchResultsAdapter(results, this.getApplicationContext()));
    } catch (Exception e) {
      Toast toast = Toast.makeText(this, "Something went wrong: " + e.getMessage(), Toast.LENGTH_LONG);;
    private ListView listView()
      return (ListView)findViewById(;
    private String getQuery() {     
      return ((EditText)findViewById(;

Java Source Code List