Android Open Source - RadiusDev Customized List View






From Project

Back to project page RadiusDev.

License

The source code is released under:

MIT License

If you think the Android project RadiusDev 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

package com.example.radiusdev;
//from   w ww  . java2  s .  c om
import java.util.ArrayList;
import java.util.HashMap;
 
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class CustomizedListView extends ListActivity{
  

    static final String KEY_ID = "contactId"; // parent node
  static final String KEY_FIRST = "firstName";
    static final String KEY_LAST = "lastName";
    static final String KEY_EMAIL = "emailAdress";
    static final String KEY_DISTANCE = "distance";
    //static final String KEY_THUMB_URL = "thumb_url";
    
    
    ListView listView;
    ArrayAdapter adapter;
    DBHelper dbTools = new DBHelper(this);
    TextView contactId;
    
    public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
    setContentView(R.layout.contact_list);
    Log.d("test",dbTools.toString());
    ArrayList<HashMap<String, String>> contactList = dbTools.getAllContacts();
    
    if(contactList.size() != 0){
      
      listView = getListView();
      adapter=new ArrayAdapter(this, contactList);
      listView.setAdapter(adapter);
      
      listView.setOnItemClickListener(new OnItemClickListener(){

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
          // TODO Auto-generated method stub
          contactId = (TextView) view.findViewById(R.id.contactId);
          
          String contactIdValue = contactId.getText().toString();
          
          Intent theIntent = new Intent(getApplication(), EditContact.class);
          
          theIntent.putExtra("contactId", contactIdValue);
          
          startActivity(theIntent);
          
        }
        
      });
    }
    }
    
    public boolean onCreateOptionsMenu(Menu menu){
    getMenuInflater().inflate(R.menu.menu, menu);
    return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item){
    super.onOptionsItemSelected(item);
    switch(item.getItemId()){
    case R.id.home:
      Intent h = new Intent(this, Main.class);
      startActivity(h);
      break;
    case R.id.profile:
      Intent i = new Intent(this, DisplayUserInfo.class);
      startActivity(i);
      break;
    case R.id.contacts:
      Intent j = new Intent(this, CustomizedListView.class);
      startActivity(j);
      break;
    case R.id.about:
      Intent k = new Intent(this, DisplayAbout.class);
      startActivity(k);
      break;
    case R.id.settings:
      Intent l = new Intent(this, UserSettings.class);
      startActivity(l);
      break;
      
    case R.id.signOut:
      Intent m = new Intent(this, Login.class);
      finish();
      startActivity(m);
      break;
    }
    return true;
  }
    
  public void showAddContact(View view){
    
    Intent theIntent = new Intent(getApplication(), NewContact.class);
    
    startActivity(theIntent);
  }

}




Java Source Code List

com.example.radiusdev.AppPreferenceActivity.java
com.example.radiusdev.ArrayAdapter.java
com.example.radiusdev.Contact.java
com.example.radiusdev.CustomizedListView.java
com.example.radiusdev.DBHelper.java
com.example.radiusdev.DisplayAbout.java
com.example.radiusdev.DisplayContactList.java
com.example.radiusdev.DisplayMapContacts.java
com.example.radiusdev.DisplayUserInfo.java
com.example.radiusdev.EditContact.java
com.example.radiusdev.EditUser.java
com.example.radiusdev.GPS.java
com.example.radiusdev.JSONparser.java
com.example.radiusdev.Login.java
com.example.radiusdev.MainActivity.java
com.example.radiusdev.Main.java
com.example.radiusdev.MapWrapperLayout.java
com.example.radiusdev.Map.java
com.example.radiusdev.NewContact.java
com.example.radiusdev.OnInfoWindowElemTouchListener.java
com.example.radiusdev.PreferencesHelper.java
com.example.radiusdev.Register.java
com.example.radiusdev.UserSettings.java
com.example.radiusdev.imageUploader.java