Android Open Source - Bluetooth-Manager-for-Glass Bluetooth Device Card Scroll Adapter

From Project

Back to project page Bluetooth-Manager-for-Glass.


The source code is released under:

MIT License

If you think the Android project Bluetooth-Manager-for-Glass 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.recursivepenguin.bluetoothmanagerforglass;
/* w  ww  .  j a  va  2s.  com*/
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import java.util.List;

public class BluetoothDeviceCardScrollAdapter extends CardScrollAdapter {
    List<BluetoothDevice> mBondedDevices;

    Context context;

    public BluetoothDeviceCardScrollAdapter(Context context, List<BluetoothDevice> devices) {
        mBondedDevices = devices;
        this.context = context;

    public void addDevice(BluetoothDevice device) {

    public int getPosition(Object item) {
        return mBondedDevices.indexOf(item);

    public int getCount() {
        return mBondedDevices.size();

    public BluetoothDevice getItem(int position) {
        return mBondedDevices.get(position);

    class ViewHolder {
        ImageView icon;
        TextView name;
        TextView address;

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.device_card, null);
            holder = new ViewHolder();

            holder.icon = (ImageView) convertView.findViewById(;
   = (TextView) convertView.findViewById(;
            holder.address = (TextView) convertView.findViewById(;

        else {
            holder = (ViewHolder) convertView.getTag();

        BluetoothDevice device = getItem(position);;

        return convertView;

Java Source Code List