Back to project page mobile-android.
The source code is released under:
MIT License
If you think the Android project mobile-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.manyconf.conference; // w w w.j ava 2s. co m import android.app.Activity; import android.app.Application; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; public class ConferenceListActivity extends Activity implements AdapterView.OnItemClickListener { private ListView mainListView; private ArrayAdapter mArrayAdapter; // LinkedHashMap<Integer, ConferenceModel> conferenceList; private ArrayList<ConferenceModel> conferenceList; @Override protected void onCreate(Bundle savedInstanceState) { Log.d("manyconf.clist", "onCreate()"); super.onCreate(savedInstanceState); conferenceList = new ArrayList(((ConferenceApplication) getApplication()).getConferenceList().values()); setContentView(R.layout.activity_conference_list); // Set this activity to react to list items being pressed mainListView = (ListView) findViewById(R.id.conference_listview); mainListView.setOnItemClickListener(this); // Create an ArrayAdapter for the ListView /* ArrayList<ConferenceModel> modelList = new ArrayList(conferenceList.values()); mArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, modelList); */ ArrayList modelList = new ArrayList(conferenceList); mArrayAdapter = new ThemedArrayAdapter(this, android.R.layout.simple_list_item_1, modelList); // Set the ListView to use the ArrayAdapter mainListView.setAdapter(mArrayAdapter); mArrayAdapter.notifyDataSetChanged(); } @Override public void onItemClick(AdapterView parent, View view, int position, long id) { Log.d("manyconf.clist", "clicked"); Intent detailIntent = new Intent(this, ConferenceDetailActivity.class); ConferenceModel cm = conferenceList.get(position); detailIntent.putExtra("conferenceListID", cm.conferenceID); startActivity(detailIntent); } /* @Override public void retrievedConferenceList(ArrayList<ConferenceModel> conferenceList) { Log.d("manyconf.main", "retrievedConferenceList()"); if(conferenceList.size() == 0) { Toast.makeText(getApplicationContext(), "Can't access network", Toast.LENGTH_SHORT).show(); Log.d("manyconf.main", "couldn't refresh from network"); return; } Log.d("manyconf.main", "updating screen with latest results"); Toast.makeText(getApplicationContext(), "Updated", Toast.LENGTH_SHORT).show(); updateListView(conferenceList); } */ /* // This may get called twice; once when the cache is parsed, and again when we're // done fetching the latest copy from the intarwebz. So it's synchronized, to avoid any hassles. synchronized public void updateListView(ArrayList<ConferenceModel> conferenceList) { this.conferenceList = conferenceList; ((ConferenceApplication) this.getApplication()).conferenceList = conferenceList; // Create an ArrayAdapter for the ListView mArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, conferenceList); // Set the ListView to use the ArrayAdapter mainListView.setAdapter(mArrayAdapter); mArrayAdapter.notifyDataSetChanged(); } */ /* @Override public void retrievedCachedConferenceList(ArrayList<ConferenceModel> conferenceList) { Log.d("manyconf.main", "retrievedCachedConferenceList()"); if(conferenceList.size() == 0) { Log.d("manyconf.main", "There wasn't any cache, not displaying anything"); return; } Log.d("manyconf.main", "Updating screen with cached copy"); updateListView(conferenceList); } */ // http://stackoverflow.com/questions/7361135/how-to-change-color-and-font-on-listview private class ConferenceListAdapter extends ArrayAdapter<String> { public ConferenceListAdapter(Context context, int textViewResourceId, String[] objects) { super(context, textViewResourceId, objects); } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView tv = (TextView) view; tv.setTypeface(Theme.current().regularFont); return view; } } }