Example usage for android.widget ListView setAdapter

List of usage examples for android.widget ListView setAdapter

Introduction

In this page you can find the example usage for android.widget ListView setAdapter.

Prototype

@Override
public void setAdapter(ListAdapter adapter) 

Source Link

Document

Sets the data behind this ListView.

Usage

From source file:com.applechip.android.showcase.rest.HttpGetGzipCompressedJsonActivity.java

private void refreshResults(ResponseEntity<TwitterSearchResults> response) {
    if (response == null) {
        return;/*from  w ww  .  j a v  a 2  s .  co m*/
    }

    HttpHeaders headers = response.getHeaders();
    StringBuilder sb = new StringBuilder();
    sb.append("Date: ").append(headers.getFirst("Date")).append("\n");
    sb.append("Status: ").append(headers.getFirst("Status")).append("\n");
    sb.append("Content-Type: ").append(headers.getFirst("Content-Type")).append("\n");
    sb.append("Content-Encoding: ").append(headers.getFirst("Content-Encoding")).append("\n");
    sb.append("Content-Length: ").append(headers.getFirst("Content-Length")).append("\n");

    TextView textView = (TextView) findViewById(R.id.text_view_headers);
    textView.setText(sb.toString());

    TwitterSearchResults results = response.getBody();

    ListView listView = (ListView) findViewById(R.id.list_view_result_items);
    listView.setAdapter(new TweetListAdapter(this, results.getResults()));
}

From source file:au.gov.ga.worldwind.androidremote.client.ui.ItemModelPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, final int position) {
    View view = inflater.inflate(R.layout.list_fragment, null);
    ListView listView = (ListView) view.findViewById(android.R.id.list);
    Item item = state.getItem(position);
    listView.setAdapter(state.createListAdapter(inflater, item, flatten));
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override//from w w  w  .  j  av  a2  s .c o  m
        public void onItemClick(AdapterView<?> parentView, View childView, int listPosition, long id) {
            state.click(position, listPosition, flatten);
        }
    });
    container.addView(view);
    return view;
}

From source file:android.support.test.testapp.DrawerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_activity);

    ListAdapter listAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.drawer_row,
            R.id.drawer_row_name, DRAWER_CONTENTS);
    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ListView drawerList = (ListView) findViewById(R.id.drawer_list);
    drawerList.setAdapter(listAdapter);

    final TextView textView = (TextView) findViewById(R.id.drawer_text_view);

    drawerList.setOnItemClickListener(new OnItemClickListener() {
        @Override//from  w ww  .  j  a va 2  s .com
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            textView.setText("You picked: " + DRAWER_CONTENTS[(int) id]);
            drawerLayout.closeDrawers();
        }
    });

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    title = getTitle();

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.nav_drawer_open,
            R.string.nav_drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(title);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(title);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
}

From source file:com.balieiro.facebook.FriendsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.friends_list_fragment, container, false);
    ListView list = (ListView) view.findViewById(R.id.list_view);
    list.setAdapter(mAdapter);
    mProgress = (LinearLayout) view.findViewById(R.id.progress_layout);

    list.setOnScrollListener(new OnScrollListener() {
        @Override// w ww  .  java  2s  .  c o  m
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            // Load more items in the bottom of this list in case user is 
            // close to the end.
            if (totalItemCount - (firstVisibleItem + visibleItemCount) < LAZY_LOAD_LIMIT
                    && totalItemCount > 0) {
                loadItems();
            }
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
    return view;
}

From source file:net.eledge.android.europeana.gui.fragment.RecordDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_record_details, null);
    ListView mListView = (ListView) root.findViewById(R.id.fragment_record_details_listview);
    mListView.setAdapter(mRecordViewAdapter);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setupClipboardAction(mListView);
    }//from  ww w .  j  a  va 2  s .  c  o  m
    return root;
}

From source file:net.alchemiestick.katana.winehqappdb.app_dialog.java

@Override
protected void onCreate(Bundle savedI) {
    super.onCreate(savedI);
    this.setContentView(R.layout.web_dlg);
    ListView lv = (ListView) this.findViewById(R.id.win_versions);
    tv = (TextView) this.findViewById(R.id.win_name);
    lv.setAdapter(this.adapter);
}

From source file:com.enadein.carlogbook.ui.FuelRateFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    adapter = new FuelRateAdapter(getActivity(), null, getMediator().getUnitFacade());
    ListView carListView = (ListView) view.findViewById(R.id.list);
    carListView.setAdapter(adapter);
    swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    swipeLayout.setColorSchemeResources(R.color.progress1, R.color.progress2, R.color.progress3,
            R.color.progress4);//  w  w w .  j  a v  a  2 s.com
    swipeLayout.setOnRefreshListener(this);
}

From source file:com.example.total_encryption.FileChoose.java

private void getDir(String dirPath) {
    myPath.setText("Location: " + dirPath);
    item = new ArrayList<String>();
    path = new ArrayList<String>();
    File f = new File(dirPath);
    File[] files = f.listFiles();
    if (files != null) {
        if (!dirPath.equals(root)) {
            item.add(root);//from  w  w w. j a va2  s .co  m
            path.add(root);
            item.add("../");
            path.add(f.getParent());
        }

        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            path.add(file.getPath());
            if (file.isDirectory())
                item.add(file.getName() + "/");
            else
                item.add(file.getName());
        }

        ArrayAdapter<String> fileList = new ArrayAdapter<String>(this, R.layout.row, item);
        ListView myListView = (ListView) findViewById(R.id.Mylist);
        myListView.setAdapter(fileList);

    }

}

From source file:com.enadein.carlogbook.ui.DataValueActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    adapter = new DataValueAdapter(this, null);

    ListView valueListView = (ListView) findViewById(R.id.list);
    valueListView.setAdapter(adapter);

    Bundle params = getIntent().getExtras();
    if (params != null) {
        type = params.getInt(BaseActivity.TYPE_KEY);
    }/*from w w w  .  jav a 2 s .co  m*/

    valueListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            getMediator().showUpdateDataValue(type, id);
        }
    });

    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getMediator().showAddDataValue(type);
        }
    });

    getSupportLoaderManager().initLoader(0, null, this);
}

From source file:io.v.positioning.BluetoothPositionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bluetoothposition);
    Button scanButton = (Button) findViewById(R.id.button_scan);
    scanButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from w  w w.j  av  a 2s  . c o  m*/
        public void onClick(View v) {
            doDiscovery();
            v.setVisibility(View.GONE);
        }
    });
    mRecordedDevices = new ArrayAdapter<String>(this, R.layout.device_name);
    ListView recordedDevicesListView = (ListView) findViewById(R.id.recorded_devices);
    recordedDevicesListView.setAdapter(mRecordedDevices);
    this.registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));
    this.registerReceiver(mReceiver, new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED));
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
}