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.abc.driver.TruckActivity.java

public void chooseTruckType(View v) {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    GridView gridView1 = new GridView(this);
    gridView1.setNumColumns(3);//ww w . j av  a  2s  .  co m
    // (GridView)findViewById(R.id.gridView1);
    SimpleAdapter adapter = new SimpleAdapter(this, mTruckTypeList, R.layout.truck_type_griditem,
            new String[] { "PIC", "TITLE", "TTYPE" },
            new int[] { R.id.griditem_pic, R.id.griditem_title, R.id.griditem_type, });

    gridView1.setAdapter(adapter);
    builder.setTitle("Please Choose");
    builder.setInverseBackgroundForced(true);
    builder.setView(gridView1);
    final Dialog dialog = builder.create();

    gridView1.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            mTTtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText());
            mTruckType = ((TextView) view.findViewById(R.id.griditem_type)).getText().toString();

            mUpdateTruckTask = new UpdateTruckTask();
            mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(), mTruckType,
                    "" + app.getUser().getMyTruck().getLengthId(),
                    "" + app.getUser().getMyTruck().getWeightId(),
                    "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId());
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.darizotas.metadatastrip.FileListFragment.java

/**
 * Updates the current Fragment with the contents of the given path.
 * @param path Current path./*from  w  w w  .  j a  va  2s . c o  m*/
 */
public void updateListAdapter(String path) {
    // Updates the current folder
    mPath = path;
    TextView currentPath = (TextView) getView().findViewById(R.id.current_path);
    currentPath.setText(path);

    // Updates the list
    mDirContents = FileManager.getDirContents(path);
    String[] from = { FileManager.KEY_ICON, FileManager.KEY_FILENAME };
    int[] to = { R.id.file_icon, R.id.file_name };
    SimpleAdapter adapter = new SimpleAdapter(getActivity(), mDirContents, R.layout.fragment_file_row, from,
            to);

    setListAdapter(adapter);
}

From source file:com.kdao.cmpe235_project.UploadActivity.java

private void initUI() {
    /**/*from w  ww  .ja v a2  s  . c o  m*/
     * This adapter takes the data in transferRecordMaps and displays it,
     * with the keys of the map being related to the columns in the adapter
     */
    simpleAdapter = new SimpleAdapter(this, transferRecordMaps, R.layout.record_item,
            new String[] { "checked", "fileName", "progress", "bytes", "state", "percentage" },
            new int[] { R.id.radioButton1, R.id.textFileName, R.id.progressBar1, R.id.textBytes, R.id.textState,
                    R.id.textPercentage });
    simpleAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            switch (view.getId()) {
            case R.id.radioButton1:
                RadioButton radio = (RadioButton) view;
                radio.setChecked((Boolean) data);
                return true;
            case R.id.textFileName:
                TextView fileName = (TextView) view;
                fileName.setText((String) data);
                return true;
            case R.id.progressBar1:
                ProgressBar progress = (ProgressBar) view;
                progress.setProgress((Integer) data);
                return true;
            case R.id.textBytes:
                TextView bytes = (TextView) view;
                bytes.setText((String) data);
                return true;
            case R.id.textState:
                TextView state = (TextView) view;
                state.setText(((TransferState) data).toString());
                return true;
            case R.id.textPercentage:
                TextView percentage = (TextView) view;
                percentage.setText((String) data);
                return true;
            }
            return false;
        }
    });
    setListAdapter(simpleAdapter);

    // Updates checked index when an item is clicked
    getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {

            if (checkedIndex != pos) {
                transferRecordMaps.get(pos).put("checked", true);
                if (checkedIndex >= 0) {
                    transferRecordMaps.get(checkedIndex).put("checked", false);
                }
                checkedIndex = pos;
                updateButtonAvailability();
                simpleAdapter.notifyDataSetChanged();
            }
        }
    });

    //btnUploadFile = (Button) findViewById(R.id.buttonUploadFile);
    btnUploadImage = (Button) findViewById(R.id.buttonUploadImage);
    btnUploadAudio = (Button) findViewById(R.id.buttonUploadAudio);
    btnUploadVideo = (Button) findViewById(R.id.buttonUploadVideo);
    btnPause = (Button) findViewById(R.id.buttonPause);
    btnResume = (Button) findViewById(R.id.buttonResume);
    btnCancel = (Button) findViewById(R.id.buttonCancel);
    btnDelete = (Button) findViewById(R.id.buttonDelete);
    btnPauseAll = (Button) findViewById(R.id.buttonPauseAll);
    btnCancelAll = (Button) findViewById(R.id.buttonCancelAll);

    btnUploadImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isTreeSelected) {
                System.out.println(">>>>> Start uploading photos... <<<<<<<");
                Intent intent = new Intent();
                if (Build.VERSION.SDK_INT >= 19) {
                    // For Android versions of KitKat or later, we use a
                    // different intent to ensure
                    // we can get the file path from the returned intent URI
                    intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
                    intent.addCategory(Intent.CATEGORY_OPENABLE);
                    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                } else {
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                }
                APIurl = "/tree/" + treeId + "/photo";
                intent.setType("image/*");
                startActivityForResult(intent, 0);
            } else {
                Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show();
            }
        }
    });

    btnUploadAudio.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isTreeSelected) {
                Intent intent = new Intent();
                if (Build.VERSION.SDK_INT >= 19) {
                    // For Android versions of KitKat or later, we use a
                    // different intent to ensure
                    // we can get the file path from the returned intent URI
                    intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
                    intent.addCategory(Intent.CATEGORY_OPENABLE);
                    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                } else {
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                }
                APIurl = "/tree/" + treeId + "/audio";
                intent.setType("audio/*");
                startActivityForResult(intent, 0);
            } else {
                Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show();
            }
        }

    });

    btnUploadVideo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isTreeSelected) {
                Intent intent = new Intent();
                if (Build.VERSION.SDK_INT >= 19) {
                    // For Android versions of KitKat or later, we use a
                    // different intent to ensure
                    // we can get the file path from the returned intent URI
                    intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
                    intent.addCategory(Intent.CATEGORY_OPENABLE);
                    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                } else {
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                }
                APIurl = "/tree/" + treeId + "/video";
                intent.setType("video/*");
                startActivityForResult(intent, 0);
            } else {
                Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show();
            }
        }
    });

    btnPause.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Make sure the user has selected a transfer
            if (checkedIndex >= 0 && checkedIndex < observers.size()) {
                Boolean paused = transferUtility.pause(observers.get(checkedIndex).getId());
                /**
                 * If paused does not return true, it is likely because the
                 * user is trying to pause an upload that is not in a
                 * pausable state (For instance it is already paused, or
                 * canceled).
                 */
                if (!paused) {
                    Toast.makeText(UploadActivity.this, Config.UPLOAD_PAUSE_ERR, Toast.LENGTH_SHORT).show();
                }
            }
        }
    });

    btnResume.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Make sure the user has selected a transfer
            if (checkedIndex >= 0 && checkedIndex < observers.size()) {
                TransferObserver resumed = transferUtility.resume(observers.get(checkedIndex).getId());
                // Sets a new transfer listener to the original observer.
                // This will overwrite existing listener.
                observers.get(checkedIndex).setTransferListener(new UploadListener());
                /**
                 * If resume returns null, it is likely because the transfer
                 * is not in a resumable state (For instance it is already
                 * running).
                 */
                if (resumed == null) {
                    Toast.makeText(UploadActivity.this, Config.UPLOAD_RESUME_ERR, Toast.LENGTH_SHORT).show();
                }
            }
        }
    });

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Make sure a transfer is selected
            if (checkedIndex >= 0 && checkedIndex < observers.size()) {
                Boolean canceled = transferUtility.cancel(observers.get(checkedIndex).getId());
                /**
                 * If cancel returns false, it is likely because the
                 * transfer is already canceled
                 */
                if (!canceled) {
                    Toast.makeText(UploadActivity.this, Config.UPLOAD_TRANSFER_ERR, Toast.LENGTH_SHORT).show();
                }
            }
        }
    });

    btnDelete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Make sure a transfer is selected
            if (checkedIndex >= 0 && checkedIndex < observers.size()) {
                transferUtility.deleteTransferRecord(observers.get(checkedIndex).getId());
                observers.remove(checkedIndex);
                transferRecordMaps.remove(checkedIndex);
                checkedIndex = INDEX_NOT_CHECKED;
                updateButtonAvailability();
                updateList();
            }
        }
    });

    btnPauseAll.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            transferUtility.pauseAllWithType(TransferType.UPLOAD);
        }
    });

    btnCancelAll.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            transferUtility.cancelAllWithType(TransferType.UPLOAD);
        }
    });

    updateButtonAvailability();
}

From source file:widgets.Graphical_List.java

@SuppressLint("HandlerLeak")
public Graphical_List(tracerengine Trac, Activity context, int id, int dev_id, String name, String type,
        String address, final String state_key, String url, final String usage, int period, int update,
        int widgetSize, int session_type, final String parameters, String model_id, int place_id,
        String place_type, SharedPreferences params) {
    super(context, Trac, id, name, "", usage, widgetSize, session_type, place_id, place_type, mytag, container);
    this.Tracer = Trac;
    this.context = context;
    this.dev_id = dev_id;
    this.id = id;
    this.usage = usage;
    this.address = address;
    //this.type = type;
    this.state_key = state_key;
    this.update = update;
    this.wname = name;
    this.url = url;
    String[] model = model_id.split("\\.");
    this.type = model[0];
    this.place_id = place_id;
    this.place_type = place_type;
    this.params = params;
    packageName = context.getPackageName();
    this.myself = this;
    this.session_type = session_type;
    this.parameters = parameters;
    setOnLongClickListener(this);
    setOnClickListener(this);

    mytag = "Graphical_List (" + dev_id + ")";
    login = params.getString("http_auth_username", null);
    password = params.getString("http_auth_password", null);

    //state key/*from   w  w w  . j  a  v  a  2s.c o m*/
    state_key_view = new TextView(context);
    state_key_view.setText(state_key);
    state_key_view.setTextColor(Color.parseColor("#333333"));

    //value
    value = new TextView(context);
    value.setTextSize(28);
    value.setTextColor(Color.BLACK);
    animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(1000);

    if (with_list) {
        //Exploit parameters
        JSONObject jparam = null;
        String command;
        JSONArray commandValues = null;
        try {
            jparam = new JSONObject(parameters.replaceAll("&quot;", "\""));
            command = jparam.getString("command");
            commandValues = jparam.getJSONArray("commandValues");
            Tracer.e(mytag, "Json command :" + commandValues);
        } catch (Exception e) {
            command = "";
            commandValues = null;
            Tracer.e(mytag, "Json command error " + e.toString());

        }
        if (commandValues != null) {
            if (commandValues.length() > 0) {
                if (known_values != null)
                    known_values = null;

                known_values = new String[commandValues.length()];
                for (int i = 0; i < commandValues.length(); i++) {
                    try {
                        known_values[i] = commandValues.getString(i);
                    } catch (Exception e) {
                        known_values[i] = "???";
                    }
                }
            }

        }
        //list of choices
        listeChoices = new ListView(context);

        listItem = new ArrayList<HashMap<String, String>>();
        list_usable_choices = new Vector<String>();
        for (int i = 0; i < known_values.length; i++) {
            list_usable_choices.add(getStringResourceByName(known_values[i]));
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("choice", getStringResourceByName(known_values[i]));
            map.put("cmd_to_send", known_values[i]);
            listItem.add(map);

        }

        SimpleAdapter adapter_map = new SimpleAdapter(getContext(), listItem, R.layout.item_choice,
                new String[] { "choice", "cmd_to_send" }, new int[] { R.id.choice, R.id.cmd_to_send });
        listeChoices.setAdapter(adapter_map);
        listeChoices.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if ((position < listItem.size()) && (position > -1)) {
                    //process selected command
                    HashMap<String, String> map = new HashMap<String, String>();
                    map = listItem.get(position);
                    cmd_requested = map.get("cmd_to_send");
                    Tracer.d(mytag,
                            "command selected at Position = " + position + "  Commande = " + cmd_requested);
                    new CommandeThread().execute();
                }
            }
        });

        listeChoices.setScrollingCacheEnabled(false);
        //feature panel 2 which will contain list of selectable choices
        featurePan2 = new LinearLayout(context);
        featurePan2.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        featurePan2.setGravity(Gravity.CENTER_VERTICAL);
        featurePan2.setPadding(5, 10, 5, 10);
        featurePan2.addView(listeChoices);

    }

    LL_featurePan.addView(value);

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            if (msg.what == 2) {
                Toast.makeText(getContext(), "Command Failed", Toast.LENGTH_SHORT).show();

            } else if (msg.what == 9999) {

                //Message from cache engine
                //state_engine send us a signal to notify value changed
                if (session == null)
                    return;

                String loc_Value = session.getValue();
                Tracer.d(mytag, "Handler receives a new value <" + loc_Value + ">");
                value.setText(getStringResourceByName(loc_Value));
                //To have the icon colored as it has no state
                IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 2));

            } else if (msg.what == 9998) {
                // state_engine send us a signal to notify it'll die !
                Tracer.d(mytag, "cache engine disappeared ===> Harakiri !");
                session = null;
                realtime = false;
                removeView(LL_background);
                myself.setVisibility(GONE);
                if (container != null) {
                    container.removeView(myself);
                    container.recomputeViewAttributes(myself);
                }
                try {
                    finalize();
                } catch (Throwable t) {
                } //kill the handler thread itself
            }
        }

    }; //End of handler

    //================================================================================
    /*
     * New mechanism to be notified by widgetupdate engine when our value is changed
     * 
     */
    WidgetUpdate cache_engine = WidgetUpdate.getInstance();
    if (cache_engine != null) {
        session = new Entity_client(dev_id, state_key, mytag, handler, session_type);
        if (tracerengine.get_engine().subscribe(session)) {
            realtime = true; //we're connected to engine
            //each time our value change, the engine will call handler
            handler.sendEmptyMessage(9999); //Force to consider current value in session
        }

    }
    //================================================================================
    //updateTimer();   //Don't use anymore cyclic refresh....   

}

From source file:fm.feed.android.testapp.fragment.TestFragment.java

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

    mBtnTune.setOnClickListener(tune);/*from w  w w .java  2s  . c  om*/
    mBtnPlay.setOnClickListener(play);
    mBtnPause.setOnClickListener(pause);
    mBtnSkip.setOnClickListener(skip);
    mBtnLike.setOnClickListener(like);
    mBtnUnlike.setOnClickListener(unlike);
    mBtnDislike.setOnClickListener(dislike);
    mBtnHistory.setOnClickListener(history);

    mPlacementsView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    mStationsView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);

    mBtnToggleWifi.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ConnectivityManager cm = (ConnectivityManager) getActivity()
                    .getSystemService(Context.CONNECTIVITY_SERVICE);

            NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
            boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

            WifiManager wifi = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
            wifi.setWifiEnabled(!isConnected); // true or false to activate/deactivate wifi

            mBtnToggleWifi.setText(!isConnected ? "Wifi ON" : "Wifi OFF");
        }
    });

    List<HashMap<String, Integer>> fillMaps = new ArrayList<HashMap<String, Integer>>();
    for (Integer p : mPlacements) {
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        map.put("Placement", p);
        fillMaps.add(map);
    }

    final SimpleAdapter adapter = new SimpleAdapter(getActivity(), fillMaps,
            android.R.layout.simple_list_item_1, new String[] { "Placement" },
            new int[] { android.R.id.text1 });
    mPlacementsView.setAdapter(adapter);
    mPlacementsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mSelectedPlacementsIndex = position;

            HashMap<String, Integer> item = (HashMap<String, Integer>) adapter.getItem(position);
            Integer placementId = item.get("Placement");
            Toast.makeText(getActivity(), placementId.toString(), Toast.LENGTH_LONG).show();
            mPlayer.setPlacementId(placementId);

        }
    });

    resetTrackInfo();

    if (mPlayer.hasPlay()) {
        updateTrackInfo(mPlayer.getPlay());
    }
    if (mPlayer.hasStationList()) {
        updateStations(mPlayer.getStationList());
    }
}

From source file:com.dsi.ant.antplus.pluginsampler.Activity_Dashboard.java

@SuppressWarnings("serial") //Suppress warnings about hash maps not having custom UIDs
@Override/*  w ww  .  ja va  2s.c  o m*/
protected void onCreate(Bundle savedInstanceState) {
    try {
        Log.i("ANT+ Plugin Sampler",
                "Version: " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
    } catch (NameNotFoundException e) {
        Log.i("ANT+ Plugin Sampler", "Version: " + e.toString());
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dashboard);
    List<Map<String, String>> menuItems = new ArrayList<Map<String, String>>();
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Heart Rate Display");
            put("desc", "Receive from HRM sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Bike Power Display");
            put("desc", "Receive from Bike Power sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Bike Cadence Display");
            put("desc", "Receive from Bike Cadence sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Bike Speed and Distance Display");
            put("desc", "Receive from Bike Speed sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Stride SDM Display");
            put("desc", "Receive from SDM sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Watch Downloader Utility");
            put("desc", "Download data from watches");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Fitness Equipment Display");
            put("desc", "Receive from a fitness equipment console");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Fitness Equipment Controls Display");
            put("desc", "Receive from controlable fitness equipment");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Blood Pressure Display");
            put("desc", "Download measurements from blood pressure sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Weight Scale Display");
            put("desc", "Receive from weight scales");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Environment Display");
            put("desc", "Receive from Tempe sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Geocache Utility");
            put("desc", "Read and program Geocache sensors");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Audio Controllable Device");
            put("desc", "Transmit audio player status and receive commands from remote control");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Audio Remote Control");
            put("desc", "Transmit audio player commands and receive status from audio controllable devices");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Video Controllable Device");
            put("desc", "Transmit video player status and receive commands from remote control");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Video Remote Control");
            put("desc", "Transmit video player commands and receive status from video controllable devices");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Generic Controllable Device");
            put("desc", "Receive generic commands from remote control");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Generic Remote Control");
            put("desc", "Transmit generic commands to a generic controllable device");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Async Scan Demo");
            put("desc", "Connect to HRM sensors using the asynchronous scan method");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Multi Device Search");
            put("desc", "Search for multiple device types on the same channel");
        }
    });
    menuItems.add(new HashMap<String, String>() {
        {
            put("title", "Launch ANT+ Plugin Manager");
            put("desc", "Controls device database and default settings");
        }
    });

    SimpleAdapter adapter = new SimpleAdapter(this, menuItems, android.R.layout.simple_list_item_2,
            new String[] { "title", "desc" }, new int[] { android.R.id.text1, android.R.id.text2 });
    setListAdapter(adapter);

    try {
        ((TextView) findViewById(R.id.textView_PluginSamplerVersion)).setText(
                "Sampler Version: " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
    } catch (NameNotFoundException e) {
        ((TextView) findViewById(R.id.textView_PluginSamplerVersion)).setText("Sampler Version: ERR");
    }
    ((TextView) findViewById(R.id.textView_PluginLibVersion))
            .setText("Built w/ PluginLib: " + PluginLibVersionInfo.PLUGINLIB_VERSION_STRING);
    ((TextView) findViewById(R.id.textView_PluginsPkgVersion))
            .setText("Installed Plugin Version: " + AntPluginPcc.getInstalledPluginsVersionString(this));
}

From source file:org.occupycincy.android.OccupyCincyActivity.java

private void populateBlogView() {
    ListView lv = (ListView) findViewById(R.id.lvBlog);
    ListAdapter la = null;//  w w  w .j a  va  2s  .  co m
    if (feedItems.isEmpty()) {
        la = new ArrayAdapter<Object>(getApplicationContext(), android.R.layout.simple_list_item_1,
                new String[] { "No data. Try again later." });
        lv.setOnItemClickListener(null);
    } else {
        la = new SimpleAdapter(getApplicationContext(), feedItems, R.layout.blog_row,
                new String[] { "title", "description" }, new int[] { R.id.txtTitle, R.id.txtDescription });

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                //setToast(feedItems.get(position).get("title"));
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(feedItems.get(position).get("link"))));
            }
        });
    }
    lv.setAdapter(la);
}

From source file:widgets.Graphical_History.java

private void getlastvalue() {
    //TODO add something in the view
    //add last 5 values with their dates
    //featurePan2.addView();
    JSONObject json_LastValues = null;//from w ww  . j  av a2s.  c om
    JSONArray itemArray = null;
    listeChoices = new ListView(context);
    ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
    try {
        json_LastValues = Rest_com.connect(url + "stats/" + dev_id + "/" + state_key + "/last/5/", login,
                password);
        itemArray = json_LastValues.getJSONArray("stats");
        for (int i = itemArray.length(); i >= 0; i--) {
            try {
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("value", itemArray.getJSONObject(i).getString("value"));
                map.put("date", itemArray.getJSONObject(i).getString("date"));
                listItem.add(map);
                Tracer.d(mytag, map.toString());
            } catch (Exception e) {
                Tracer.e(mytag, "Error getting json value");
            }
        }
    } catch (Exception e) {
        //return null;
        Tracer.e(mytag, "Error getting json object");
    }

    SimpleAdapter adapter_feature = new SimpleAdapter(this.context, listItem, R.layout.item_phone,
            new String[] { "value", "date" }, new int[] { R.id.phone_value, R.id.phone_date });
    listeChoices.setAdapter(adapter_feature);
    listeChoices.setScrollingCacheEnabled(false);
}

From source file:com.abc.driver.TruckActivity.java

public void chooseTruckLength(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    GridView gridView1 = new GridView(this);
    gridView1.setNumColumns(3);/*from   w  w w. j av  a  2 s .c o m*/
    // (GridView)findViewById(R.id.gridView1);
    SimpleAdapter adapter = new SimpleAdapter(this, mTruckLengthList, R.layout.truck_length_griditem,
            new String[] { "TITLE", "TLENGTH" }, new int[] { R.id.griditem_title, R.id.griditem_length, });

    gridView1.setAdapter(adapter);
    builder.setTitle("Please Choose");
    builder.setInverseBackgroundForced(true);
    builder.setView(gridView1);
    final Dialog dialog = builder.create();

    gridView1.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
            mTLtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText());
            mTruckLength = ((TextView) view.findViewById(R.id.griditem_length)).getText().toString();
            mUpdateTruckTask = new UpdateTruckTask();
            mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(),
                    "" + app.getUser().getMyTruck().getTypeId(), mTruckLength,
                    "" + app.getUser().getMyTruck().getWeightId(),
                    "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId());

            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:org.developfreedom.ccdroid.app.MainActivity.java

private SimpleAdapter getAdapterFor(List<Project> projects) {
    List<HashMap<String, String>> dataList = new ArrayList<HashMap<String, String>>();

    for (Project project : projects) {
        HashMap<String, String> hashMap = new HashMap<String, String>();
        int drawableId = getDrawableId(project.getLastBuildStatus(), project.getActivity());

        hashMap.put("flag", Integer.toString(drawableId));
        hashMap.put("name", project.getName());
        hashMap.put("activity", project.getActivity());
        hashMap.put("time", project.getLastBuildTime());
        hashMap.put("label", project.getLastBuildLabel());
        hashMap.put("url", project.getWebUrl());

        dataList.add(hashMap);//  w  ww  .j  a  va  2 s.com
    }

    String[] keysInDataHashmap = { "activity", "flag", "name", "time", };
    int[] valuesIdInListviewLayout = { R.id.lw_project_activity, R.id.lw_status_flag, R.id.lw_project_name,
            R.id.lw_project_time, };

    SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), dataList, R.layout.list_row_layout_project, //this layout defines the layout of each item
            keysInDataHashmap, valuesIdInListviewLayout);
    return adapter;
}