Example usage for android.widget SimpleAdapter SimpleAdapter

List of usage examples for android.widget SimpleAdapter SimpleAdapter

Introduction

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

Prototype

public SimpleAdapter(Context context, List<? extends Map<String, ?>> data, @LayoutRes int resource,
        String[] from, @IdRes int[] to) 

Source Link

Document

Constructor

Usage

From source file:com.telestax.restcomm_olympus.MessageFragment.java

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

    contactList = new ArrayList<Map<String, String>>();

    String[] from = { "username", "message-text" };
    int[] to = { R.id.message_username, R.id.message_text };

    listViewAdapter = new SimpleAdapter(getActivity().getApplicationContext(), contactList,
            R.layout.message_row_layout, from, to);
    setListAdapter(listViewAdapter);//ww w .ja v a 2 s. com
}

From source file:org.sufficientlysecure.keychain.ui.ImportKeysListFragment.java

/**
 * Define Adapter and Loader on create of Activity
 *///from  ww  w. j a v  a2s . c  om
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mActivity = this.getActivity();

    mKeyringBytes = getArguments().getByteArray(ARG_KEYRING_BYTES);
    mImportFilename = getArguments().getString(ARG_IMPORT_FILENAME);

    // register long press context menu
    registerForContextMenu(getListView());

    // Give some text to display if there is no data. In a real
    // application this would come from a resource.
    setEmptyText(mActivity.getString(R.string.error_nothingImport));

    // Create an empty adapter we will use to display the loaded data.
    String[] from = new String[] {};
    int[] to = new int[] {};
    List<Map<String, String>> data = new ArrayList<Map<String, String>>();
    mAdapter = new SimpleAdapter(getActivity(), data, android.R.layout.two_line_list_item, from, to);
    setListAdapter(mAdapter);

    // Start out with a progress indicator.
    setListShown(false);

    // Prepare the loader. Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}

From source file:br.unisinos.evertonlucas.passshelter.app.SendResourceGroupActivity.java

public void loadListAdapter(ListView listView, List<String> names, int resource) {
    String[] from = { "name" };
    int[] to = { R.id.txt_send_resource_group };
    SimpleAdapter adapter = new SimpleAdapter(this, listResources(names), resource, from, to);
    listView.setAdapter(adapter);//  w w w. j av a  2  s  .  co  m
}

From source file:ch.eitchnet.android.mabea.activity.TodayFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Logger.i(TAG, "onCreateView", "called");
    this.rootView = inflater.inflate(R.layout.fragment_today_layout, container, false);

    this.progressBar = (ProgressBar) this.rootView.findViewById(R.id.progressBar);
    this.progressBar.setVisibility(View.INVISIBLE);

    this.toggleStateBtn = (ToggleButton) this.rootView.findViewById(R.id.toggleLoggedIn);

    this.bookingsToday = (ListView) this.rootView.findViewById(R.id.bookingsToday);
    List<? extends Map<String, ?>> data = new ArrayList<Map<String, ?>>();
    int resource = R.layout.list_item_booking_today;
    String[] from = new String[] {};
    int[] to = new int[] {};
    SimpleAdapter adapter = new SimpleAdapter(getActivity(), data, resource, from, to);

    this.bookingsToday.setAdapter(adapter);

    registerObservers();/*from w  w  w  . java  2s  .  c  o  m*/

    return this.rootView;
}

From source file:it.uniroma2.foundme.studente.ShowCourseActivity.java

public static void populateView(String[] result) {
    courses = new String[result.length];
    System.arraycopy(result, 0, courses, 0, result.length);
    List<Map<String, String>> data = new ArrayList<Map<String, String>>();

    for (int i = 0; i < result.length; i++) {
        Map<String, String> datum = new HashMap<String, String>(2);
        if (i == 0 && result[0].equalsIgnoreCase(Variables_it.NO_COURSE)) {
            datum.put(Variables_it.COURSE, result[0]);
            datum.put(Variables_it.PROF, "");
            data.add(datum);/*from  w  ww  .j ava2 s  .  c o m*/
            break;
        } else {
            String[] items = result[i].split(",");
            datum.put(Variables_it.COURSE, items[0]);
            datum.put(Variables_it.PROF, items[1]);
            data.add(datum);
        }
    }
    //creo l'adapter
    SimpleAdapter adapter = new SimpleAdapter(context, data, android.R.layout.simple_list_item_2,
            new String[] { Variables_it.COURSE, Variables_it.PROF },
            new int[] { android.R.id.text1, android.R.id.text2 });
    lvCorsiSeguiti.setAdapter(adapter);

    swipeShow.setColorSchemeColors(0xff429874, 0xffffffff, 0xff429874, 0xffffffff);
    swipeShow.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeShow.setRefreshing(true);
            (new Handler()).postDelayed(new Runnable() {
                @Override
                public void run() {
                    swipeShow.setRefreshing(false);
                    try {
                        getCourse(false);
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }, 3000);
        }
    });

    lvCorsiSeguiti.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!courses[position].equalsIgnoreCase(Variables_it.NO_COURSE)) {
                Intent i = new Intent(context, CourseActivity.class);
                i.putExtra(Variables_it.COURSE, courses[position]);
                ((Activity) context).startActivity(i);
            }
        }
    });

    lvCorsiSeguiti.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {

        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
            if (firstVisibleItem == 0)
                swipeShow.setEnabled(true);
            else
                swipeShow.setEnabled(false);
        }
    });
}

From source file:com.google.sample.aaudio.play.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mPlaybackDeviceSpinner = findViewById(R.id.playbackDevicesSpinner);
    mPlaybackDeviceSpinner.setDirectionType(AudioManager.GET_DEVICES_OUTPUTS);
    mPlaybackDeviceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//  ww  w . jav  a2  s.c o m
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            PlaybackEngine.setAudioDeviceId(getPlaybackDeviceId());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    mBufferSizeSpinner = findViewById(R.id.bufferSizeSpinner);
    mBufferSizeSpinner.setAdapter(new SimpleAdapter(this, createBufferSizeOptionsList(), // list of buffer size options
            R.layout.buffer_sizes_spinner, // the xml layout
            new String[] { getString(R.string.buffer_size_description_key) }, // field to display
            new int[] { R.id.bufferSizeOption })); // View to show field in

    mBufferSizeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            PlaybackEngine.setBufferSizeInBursts(getBufferSizeInBursts());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    // initialize native audio system
    mEngineCreated = PlaybackEngine.create();

    // Periodically update the UI with the output stream latency
    mLatencyText = findViewById(R.id.latencyText);
    setupLatencyUpdater();
}

From source file:org.adaway.ui.ScanAdwareListFragment.java

/**
 * Define Adapter and Loader on create of Activity
 *//*w  w w .j a  va  2s  .c o m*/
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mActivity = this.getActivity();
    mStartButton = (Button) mActivity.findViewById(R.id.scan_adware_start_button);

    // register long press context menu
    registerForContextMenu(getListView());

    // Give some text to display if there is no data. In a real
    // application this would come from a resource.
    setEmptyText(mActivity.getString(R.string.scan_adware_empty));

    // Create an empty adapter we will use to display the loaded data.
    String[] from = new String[] {};
    int[] to = new int[] {};
    List<Map<String, String>> data = new ArrayList<Map<String, String>>();
    mAdapter = new SimpleAdapter(getActivity(), data, android.R.layout.two_line_list_item, from, to);
    setListAdapter(mAdapter);

    // Start out with a progress indicator.
    setListShown(false);
}

From source file:it.uniroma2.foundme.studente.UnFollowCourseActivity.java

public static void populateView(String[] result) {
    courses = new String[result.length];
    System.arraycopy(result, 0, courses, 0, result.length);
    List<Map<String, String>> data = new ArrayList<Map<String, String>>();

    for (int i = 0; i < result.length; i++) {
        Map<String, String> datum = new HashMap<String, String>(2);
        if (i == 0 && result[0].equalsIgnoreCase(Variables_it.NO_COURSE)) {
            datum.put(Variables_it.COURSE, result[0]);
            datum.put(Variables_it.PROF, "");
            data.add(datum);//from   ww w .  jav  a2s.  co  m
            break;
        } else {
            String[] items = result[i].split(",");
            datum.put(Variables_it.COURSE, items[0]);
            datum.put(Variables_it.PROF, items[1]);
            data.add(datum);
        }
    }
    //creo l'adapter
    SimpleAdapter adapter = new SimpleAdapter(context, data, android.R.layout.simple_list_item_2,
            new String[] { Variables_it.COURSE, Variables_it.PROF },
            new int[] { android.R.id.text1, android.R.id.text2 });
    lvCorsiSeguiti.setAdapter(adapter);

    swipeUnfollow.setColorSchemeColors(0xff429874, 0xffffffff, 0xff429874, 0xffffffff);
    swipeUnfollow.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeUnfollow.setRefreshing(true);
            (new Handler()).postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        getCourse(false);
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    swipeUnfollow.setRefreshing(false);
                }
            }, 3000);
        }
    });

    lvCorsiSeguiti.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!courses[position].equalsIgnoreCase(Variables_it.NO_COURSE))
                alertMessage(courses[position]);
        }
    });

    lvCorsiSeguiti.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {

        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
            if (firstVisibleItem == 0)
                swipeUnfollow.setEnabled(true);
            else
                swipeUnfollow.setEnabled(false);
        }
    });
}

From source file:net.sharermax.mword.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about);//from  w w  w . j a  v a 2s . c o m
    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(getApplicationContext());
    //
    mSwipeBackEnable = sharedPreferences.getBoolean(PreferenceKey.SWIPE_BACK_KEY, true);
    mSwipeBackLayout = getSwipeBackLayout();
    if (mSwipeBackEnable) {
        //               Log.v("BASIC", "YYY");
        mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
    } else {
        setSwipeBackEnable(false);
    }

    mImmersionEnable = sharedPreferences.getBoolean(PreferenceKey.IMMERSION_KEY, true);
    if (mImmersionEnable && android.os.Build.VERSION.SDK_INT > 18) {
        Window window = getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

    }

    getActionBar().setDisplayHomeAsUpEnabled(true);
    mlistView = (ListView) findViewById(R.id.about_listview);
    //      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, getData());
    //      listView.setAdapter(adapter);
    //      listView.setText
    SimpleAdapter adapter = new SimpleAdapter(this, getData(), R.layout.about_item,
            new String[] { "text1", "text2" }, new int[] { R.id.text1, R.id.text2 });
    mlistView.setAdapter(adapter);
    mlistView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub

            switch (arg2) {
            case 0:
                //               Log.v("listview", "0");
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://sharermax.net/%E5%85%B3%E4%BA%8E%E6%88%91/"));
                startActivity(intent);
                break;
            case 1:
                //               Log.v("listview", "1");
                Intent intent1 = new Intent(Intent.ACTION_VIEW);
                intent1.setData(Uri.parse("http://git.oschina.net/watermelon/MWord"));
                startActivity(intent1);
                break;
            case 2:
                //               Log.v("listview", "2");
                Intent intent2 = new Intent(Intent.ACTION_VIEW);
                intent2.setData(Uri.parse("http://git.oschina.net/watermelon/MWord/raw/master/LICENSE"));
                startActivity(intent2);
                break;
            case 3:
                break;
            case 4:
                //               Log.v("listview", "4");
                Intent intent4 = new Intent(Intent.ACTION_SENDTO);
                intent4.setData(Uri.parse("mailto:mdcw1103@gmail.com"));
                startActivity(Intent.createChooser(intent4, ""));
                break;
            case 5:
                //               Log.v("listview", "5");
                UpdateApp updateApp = new UpdateApp(AboutActivity.this, UpdateApp.VERSION_TYPE_BETA);
                updateApp.setTaskOverListener(new TaskOverListener() {

                    @Override
                    public void taskOver(int versionCode) {
                        // TODO Auto-generated method stub
                        PackageManager packageManager = AboutActivity.this.getPackageManager();
                        try {
                            PackageInfo packageInfo = packageManager
                                    .getPackageInfo(AboutActivity.this.getPackageName(), 0);
                            //                        Log.v("UPDATE", "" + versionCode);
                            if (versionCode > packageInfo.versionCode) {

                                Toast.makeText(getApplicationContext(), "", Toast.LENGTH_LONG).show();
                                UpdateApp.updateNotification(AboutActivity.this);
                            } else {
                                Toast.makeText(getApplicationContext(), "", Toast.LENGTH_LONG)
                                        .show();
                            }
                        } catch (NameNotFoundException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });
                updateApp.startTask();
                break;
            default:
                break;
            }

        }
    });
}

From source file:bus_vn.gena.bus_vn.com.bus_vn.tabs.Tab_list_bus.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    DbOpenHelper dbOpenHelper = new DbOpenHelper(getActivity());
    SQLiteDatabase db;/*from w w w .j a  va 2  s .  c o  m*/
    db = dbOpenHelper.getWritableDatabase();
    ContentValues cv = new ContentValues();
    cv.clear();
    String st;
    st = "SELECT Name FROM bus_path_table  WHERE bus_path_table.Type_transport_id='" + typeTransport + "'"
            + "ORDER BY Number";
    Cursor c = db.rawQuery(st, null);
    while (c.moveToNext()) {
        String st2 = "";
        st2 = c.getString(0);
        results.add(st2);
    }
    //  ??
    gridView = (GridView) getView().findViewById(R.id.gridview);
    //? ClickListener ? listview
    gridView.setOnItemClickListener((android.widget.AdapterView.OnItemClickListener) this);
    dataList = new ArrayList<Map<String, Object>>();
    dataList = getData();
    //? ClickListener ? gridView
    simpleAdapter = new SimpleAdapter(getActivity(), dataList, R.layout.gridview_item,
            new String[] { "image", "text" }, new int[] { R.id.image, R.id.text });
    //     listview
    gridView.setAdapter(simpleAdapter);
}