Code example for ListView

Methods: setAdapter, setOnItemClickListener

0
public class Docks extends SherlockActivity implements AdapterView.OnItemClickListener{
    public Uri CONTENT_URI;
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ListView lv=new ListView(this);
        lv.setAdapter(new DocksAdapter(this));
        lv.setOnItemClickListener(this);
        setContentView(lv);
        CONTENT_URI=Uri.parse("content://"+DocksProvider.class.getCanonicalName());
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        String dock=adapterView.getItemAtPosition(i).toString();
        Intent result = new Intent(null, Uri.withAppendedPath(CONTENT_URI,dock));
        setResult(RESULT_OK, result);
        finish(); 
    } 
    private class DocksAdapter extends BaseAdapter{
        public DocksAdapter(Context mContext) {