Example usage for android.widget AdapterView getItemAtPosition

List of usage examples for android.widget AdapterView getItemAtPosition

Introduction

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

Prototype

public Object getItemAtPosition(int position) 

Source Link

Document

Gets the data associated with the specified position in the list.

Usage

From source file:com.housekeeper.ar.healthhousekeeper.RegisterActivity.java

private void setSpinner() {
    Log.i(TAG, "namePros:" + namePros);
    //      ArrayAdapter<String> proAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,namePros){
    //         @Override
    //         public View getDropDownView(int position, View convertView, ViewGroup parent) {
    //            LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //            View view = inflater.inflate(R.layout.spinner_item_layout,
    //                  null);
    //            TextView label = (TextView) view
    //                  .findViewById(R.id.spinner_item_label);
    ///*  w ww  . j av a 2 s .co  m*/
    //            label.setText(namePros[position]);
    //
    //
    //            return view;
    //            //return super.getDropDownView(position, convertView, parent);
    //         }
    //      };
    //
    //      //?
    //      proAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
    ////      proAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    //      pro.setAdapter(proAdapter);
    //      pro.setOnItemSelectedListener(new OnItemSelectedListener() {
    //
    //         @Override
    //         public void onItemSelected(AdapterView<?> parent, View view,
    //                              int position, long id) {
    //            // TODO Auto-generated method stub
    //            proStr = parent.getItemAtPosition(position).toString();
    //            Log.v(TAG, "selcet proStr:" + proStr);
    //            if (proStr.equals(namePros[position])) {
    //               idJobTitlesInt = idJobTitles[position];
    //            }
    //         }
    //
    //         @Override
    //         public void onNothingSelected(AdapterView<?> arg0) {
    //            // TODO Auto-generated method stub
    //
    //         }
    //
    //      });
    //
    //      pro.setOnTouchListener(new View.OnTouchListener() {
    //         @Override
    //         public boolean onTouch(View view, MotionEvent motionEvent) {
    //
    //            Log.i(TAG, "year touch ");
    //            closeSoftKeyboard();
    //            return false;
    //         }
    //      });
    ArrayAdapter<String> shengAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, nameProvinces) {
        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.spinner_item_layout, null);
            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

            label.setText(nameProvinces[position]);

            return view;
            //return super.getDropDownView(position, convertView, parent);
        }
    };

    //?
    shengAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
    sheng.setAdapter(shengAdapter);
    sheng.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> shengparent, View shengview, int shengposition,
                long shengid) {
            // TODO Auto-generated method stub
            myApp.setShengposition(shengposition);
            shengStr = shengparent.getItemAtPosition(shengposition).toString();
            Log.v(TAG, "shengStr:" + shengStr);

            if (!shengStr.equals("") && shengStr.equals(nameProvinces[shengposition])) {
                Log.v(TAG, "position:" + shengposition);
                for (int i = 0; i < joProvinces.length; i++) {
                    try {

                        if (shengStr.equals(joProvinces[i].getString("name"))) {
                            jaCities = joProvinces[i].getJSONArray("cities");
                            joCities = new JSONObject[jaCities.length()];
                            nameCities = new String[joCities.length];

                            for (int j = 0; j < jaCities.length(); j++) {
                                joCities[j] = jaCities.getJSONObject(j);
                                nameCities[j] = joCities[j].getString("name");
                            }
                        }
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block

                        e.printStackTrace();
                    }
                }
            }
            sheng.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionEvent) {

                    Log.i(TAG, "year touch ");
                    closeSoftKeyboard();
                    return false;
                }
            });
            shiAdapter = new ArrayAdapter<String>(RegisterActivity.this, R.layout.spinner_item, nameCities) {
                @Override
                public View getDropDownView(int position, View convertView, ViewGroup parent) {
                    LayoutInflater inflater = (LayoutInflater) getContext()
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View view = inflater.inflate(R.layout.spinner_item_layout, null);
                    TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

                    label.setText(nameCities[position]);

                    return view;
                    //return super.getDropDownView(position, convertView, parent);
                }
            };

            //?
            shiAdapter.setDropDownViewResource(R.layout.spinner_item_layout);

            //            shiAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            shi.setAdapter(shiAdapter);

            shi.setOnItemSelectedListener(new OnItemSelectedListener() {

                @Override
                public void onItemSelected(AdapterView<?> shiparent, View shiview, int shiposition,
                        long shiid) {
                    // TODO Auto-generated method stub
                    shiStr = shiparent.getItemAtPosition(shiposition).toString();
                    Log.v(TAG, "shiStr:" + shiStr);
                    if (!shiStr.equals("") && shiStr.equals(nameCities[shiposition])) {
                        for (int i = 0; i < joCities.length; i++) {
                            try {
                                if (shiStr.equals(joCities[i].getString("name"))) {
                                    jaHospitals = joCities[i].getJSONArray("hospitals");
                                    joHospitals = new JSONObject[jaHospitals.length()];
                                    nameHospitals = new String[joHospitals.length];
                                    for (int j = 0; j < jaHospitals.length(); j++) {
                                        joHospitals[j] = jaHospitals.getJSONObject(j);
                                        nameHospitals[j] = joHospitals[j].getString("name");
                                    }

                                }
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block

                                e.printStackTrace();
                            }
                        }
                    }
                    shi.setOnTouchListener(new View.OnTouchListener() {
                        @Override
                        public boolean onTouch(View view, MotionEvent motionEvent) {

                            Log.i(TAG, "year touch ");
                            closeSoftKeyboard();
                            return false;
                        }
                    });
                    hospitalAdapter = new ArrayAdapter<String>(RegisterActivity.this, R.layout.spinner_item,
                            nameHospitals) {
                        @Override
                        public View getDropDownView(int position, View convertView, ViewGroup parent) {
                            LayoutInflater inflater = (LayoutInflater) getContext()
                                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            View view = inflater.inflate(R.layout.spinner_item_layout, null);
                            TextView label = (TextView) view.findViewById(R.id.spinner_item_label);

                            label.setText(nameHospitals[position]);

                            return view;
                            //return super.getDropDownView(position, convertView, parent);
                        }
                    };

                    //?
                    hospitalAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
                    yy.setAdapter(hospitalAdapter);

                    yy.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> yyparent, View yyview, int yyposition,
                                long yyid) {
                            // TODO Auto-generated method stub
                            yyStr = yyparent.getItemAtPosition(yyposition).toString();
                            if (!yyStr.equals("") && yyStr.equals(nameHospitals[yyposition])) {
                                for (int i = 0; i < joHospitals.length; i++) {
                                    try {
                                        if (yyStr.equals(joHospitals[i].getString("name"))) {
                                            jaDepartments = joHospitals[i].getJSONArray("departments");
                                            joDepartments = new JSONObject[jaDepartments.length()];
                                            nameDepartments = new String[joDepartments.length];
                                            idDepartments = new int[joDepartments.length];
                                            for (int j = 0; j < jaDepartments.length(); j++) {
                                                joDepartments[j] = jaDepartments.getJSONObject(j);
                                                nameDepartments[j] = joDepartments[j].getString("name");
                                                idDepartments[j] = joDepartments[j].getInt("id");

                                            }

                                        }
                                    } catch (JSONException e) {
                                        // TODO Auto-generated catch block

                                        e.printStackTrace();
                                    }
                                }
                            }
                            yy.setOnTouchListener(new View.OnTouchListener() {
                                @Override
                                public boolean onTouch(View view, MotionEvent motionEvent) {

                                    Log.i(TAG, "year touch ");
                                    closeSoftKeyboard();
                                    return false;
                                }
                            });
                            //                        departmentAdapter = new ArrayAdapter<String>(RegisterActivity.this, android.R.layout.simple_spinner_item, nameDepartments) {
                            //                           @Override
                            //                           public View getDropDownView(int position, View convertView, ViewGroup parent) {
                            //                              LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                            //                              View view = inflater.inflate(R.layout.spinner_item_layout,
                            //                                    null);
                            //                              TextView label = (TextView) view
                            //                                    .findViewById(R.id.spinner_item_label);
                            //
                            //                              label.setText(nameDepartments[position]);
                            //
                            //
                            //                              return view;
                            //                              //return super.getDropDownView(position, convertView, parent);
                            //                           }
                            //                        };

                            //?
                            //                        departmentAdapter.setDropDownViewResource(R.layout.spinner_item_layout);
                            //                        ks.setAdapter(departmentAdapter);
                            //                        ks.setOnItemSelectedListener(new OnItemSelectedListener() {
                            //
                            //                           @Override
                            //                           public void onItemSelected(
                            //                                 AdapterView<?> ksparent, View ksview,
                            //                                 int ksposition, long ksid) {
                            //                              // TODO Auto-generated method stub
                            //                              ksStr = ksparent.getItemAtPosition(ksposition).toString();
                            //                              if (ksStr.equals(nameDepartments[ksposition])) {
                            //                                 try {
                            //                                    idDepartmentInt = idDepartments[ksposition];
                            //                                    joDepartmentType = joDepartments[ksposition].getJSONObject("departmentType");
                            //                                    departmentTypeTv.setText(joDepartmentType.getString("name"));
                            //                                 } catch (JSONException e) {
                            //                                    // TODO Auto-generated catch block
                            //
                            //                                    e.printStackTrace();
                            //                                 }
                            //                              }
                            //                           }
                            //
                            //                           @Override
                            //                           public void onNothingSelected(
                            //                                 AdapterView<?> arg0) {
                            //                              // TODO Auto-generated method stub
                            //
                            //                           }
                            //                        });
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> arg0) {
                            // TODO Auto-generated method stub

                        }
                    });
                    //                  ks.setOnTouchListener(new View.OnTouchListener() {
                    //                     @Override
                    //                     public boolean onTouch(View view, MotionEvent motionEvent) {
                    //
                    //                        Log.i(TAG, "year touch ");
                    //                        closeSoftKeyboard();
                    //                        return false;
                    //                     }
                    //                  });
                }

                @Override
                public void onNothingSelected(AdapterView<?> arg0) {
                    // TODO Auto-generated method stub

                }
            });

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });

    year.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            yearStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub   
        }
    });
    month.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            monthStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub   
        }
    });
    day.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            dayStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub   
        }
    });
    sex.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            sexStr = parent.getItemAtPosition(position).toString();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub   
        }
    });

}

From source file:com.juick.android.MessagesFragment.java

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    JuickMessage jmsg = (JuickMessage) parent.getItemAtPosition(position);
    if (jmsg == preventClickOn)
        return;//from ww w .  j a v  a2s  .c  om
    if (doOnClick != null) {
        if (System.currentTimeMillis() < doOnClickActualTime + 1000) {
            doOnClick.run();
        }
        doOnClick = null;
        return;
    }
    Intent i = new Intent(getActivity(), ThreadActivity.class);
    i.putExtra("mid", jmsg.getMID());
    MessagesSource lightSource = messagesSource.clone();
    lightSource.cleanCloneFromCache();
    i.putExtra("messagesSource", lightSource);
    i.putExtra("originalMessage", jmsg);
    if (jmsg.contextPost != null && messagesSource instanceof JAUnansweredMessagesSource) {
        i.putExtra("prefetched", jmsg);
    }
    long l = System.currentTimeMillis();
    startActivity(i);
    l = System.currentTimeMillis() - l;
    Toast.makeText(getActivity(), "Activity start time: " + l + " msec", Toast.LENGTH_LONG);
    getActivity().overridePendingTransition(R.anim.enter_slide_to_left, R.anim.leave_lower_and_dark);
}

From source file:br.liveo.ndrawer.ui.fragment.FragmentNotificationsfacebook.java

@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long l) {

    Log.i("item long click2", "click2");
    //// ww  w . j a v  a  2  s  . co  m
    //        Notification newnote=(Notification)parent.getItemAtPosition(position);
    //        String newstring=newnote.noti;
    //
    //        SQLiteDatabase db=helper.getWritableDatabase();
    //        ContentValues cv = new ContentValues();
    //        cv.put(NotificationSquliteOpenHelper.NOTIFICATION, newstring);
    //
    //        db.delete(NotificationSquliteOpenHelper.NOTIFICATION_TABLE, NotificationSquliteOpenHelper.NOTIFICATION+"= '"+newstring+"'", null);
    //
    //
    //        data2.remove(position);
    //        adapter2.notifyDataSetChanged();

    // _selectedItem = (String)lv.getItemAtPosition(position);

    Notification newnote = (Notification) parent.getItemAtPosition(position);
    newstring = newnote.noti;

    final SQLiteDatabase db = helper.getWritableDatabase();
    ContentValues cv = new ContentValues();
    cv.put(NotificationSquliteOpenHelper.NOTIFICATION, newstring);

    // db.delete(NotificationSquliteOpenHelper.NOTIFICATION_TABLE, NotificationSquliteOpenHelper.NOTIFICATION+"= '"+newstring+"'", null);

    //  data2.remove(position);
    //   adapter2.notifyDataSetChanged();

    pos = position;
    //  par=parent;
    getActivity().openContextMenu(lv);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    //alertDialogBuilder.setView(R.layout.sig_layout);

    alertDialogBuilder.setTitle("Delete this post ?");

    // alertDialogBuilder.setMessage("helwodosfoasdoifasdofudasofudso");

    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                //Yes button clicked
                Log.i("button", "postitive button");

                db.delete(NotificationSquliteOpenHelper.NOTIFICATION_TABLE,
                        NotificationSquliteOpenHelper.NOTIFICATION + "= '" + newstring + "'", null);

                data2.remove(pos);
                adapter2.notifyDataSetChanged();

                reloadfragment();
                reloadfragment();
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                //No button clicked
                break;
            }
        }
    };

    //  ImageView iv=null;
    //  iv.setImageResource(R.drawable.example);

    // alertDialogBuilder.setCustomTitle(iv);
    alertDialogBuilder.setNegativeButton("No", dialogClickListener);
    alertDialogBuilder.setPositiveButton("Yes", dialogClickListener);

    // alertDialogBuilder.setPositiveButton("bUtton 1", );

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();

    return true;
}

From source file:org.brandroid.openmanager.fragments.ContentFragment.java

public void onItemClick(AdapterView<?> list, View view, int pos, long id) {
    OpenPath file = (OpenPath) list.getItemAtPosition(pos);

    Logger.LogInfo("File clicked: " + file.getPath());

    if (file.isArchive() && file instanceof OpenFile && Preferences.Pref_Zip_Internal)
        file = new OpenZip((OpenFile) file);

    if (getClipboard().isMultiselect()) {
        if (getClipboard().contains(file)) {
            getClipboard().remove(file);
            if (getClipboard().size() == 0)
                getClipboard().stopMultiselect();
            ((BaseAdapter) list.getAdapter()).notifyDataSetChanged();
        } else {/* w  ww .  j  ava 2 s . c o m*/
            //Animation anim = Animation.
            /*
            Drawable dIcon = ((ImageView)view.findViewById(R.id.content_icon)).getDrawable();
            if(dIcon instanceof BitmapDrawable)
            {
               IconAnimationPanel panel = new IconAnimationPanel(getExplorer())
                  .setIcon(((BitmapDrawable)dIcon).getBitmap())
                  .setStart(new Point(view.getLeft(), view.getRight()))
                  .setEnd(new Point(getActivity().getWindow().getWindowManager().getDefaultDisplay().getWidth() / 2, getActivity().getWindowManager().getDefaultDisplay().getHeight()))
                  .setDuration(500);
               ((ViewGroup)getView()).addView(panel);
            }
            */

            addToMultiSelect(file);
            ((TextView) view.findViewById(R.id.content_text)).setTextAppearance(list.getContext(),
                    R.style.Highlight);
        }
        return;
    }

    if (file.isDirectory() && !mActionModeSelected) {
        /* if (mThumbnail != null) {
           mThumbnail.setCancelThumbnails(true);
           mThumbnail = null;
        } */

        //setContentPath(file, true);
        getExplorer().onChangeLocation(file);

    } else if (!file.isDirectory() && !mActionModeSelected) {

        if (file.requiresThread() && FileManager.hasOpenCache(file.getAbsolutePath())) {
            //getExplorer().showToast("Still need to handle this.");
            if (file.isTextFile())
                getExplorer().editFile(file);
            else {
                showCopyFromNetworkDialog(file);
                //getEventHandler().copyFile(file, mPath, mContext);
            }
            return;
        } else if (file.isTextFile() && Preferences.Pref_Text_Internal)
            getExplorer().editFile(file);
        else if (!IntentManager.startIntent(file, getExplorer(), Preferences.Pref_Intents_Internal))
            getExplorer().editFile(file);
    }
}

From source file:com.openatk.field_work.MainActivity.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

    // Spinner selected item
    Operation operation = (Operation) parent.getItemAtPosition(pos);
    if (operation.getId() == null) {
        // Create new operation
        selectCurrentOperationInSpinner(); // Go back to original for now,
        // in case cancel
        createOperation(null);//from ww w  .j  ava 2  s.  co m
    } else {
        if (currentOperation == null || currentOperation.getId() != operation.getId())
            hideFragmentJob(true);

        currentOperation = operation;

        // Save this choice in preferences for next open
        SharedPreferences prefs = getApplicationContext().getSharedPreferences("com.openatk.field_work",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt("currentOperationId", currentOperation.getId());
        editor.commit();
    }

    updateOperation();
    if (this.fragmentListView != null)
        this.fragmentListView.getData();
}

From source file:org.opendatakit.tables.activities.TableDisplayActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    String all = extras.getString("all");
    loc = extras.getString("loc");
    timten = extras.getString("timten");
    keyloc = extras.getString("loc_position");
    sapxep = extras.getString("oder");
    timkiem = extras.getString("timkiem");
    page = extras.getString("page");
    key = extras.getString("vitri");
    oder_check = extras.getString("oder_position");
    if (key != null) {
        this.position_check = Integer.parseInt(key);
    }/*  w w w.  j ava 2s .com*/
    if (oder_check != null) {
        this.oder_position = Integer.parseInt(oder_check);
    }
    if (keyloc != null) {
        this.loc_position = Integer.parseInt(keyloc);
    }
    if ("null".equals(timkiem)) {
        timkiem = null;
        position_check = 0;
    }

    // see if we saved the state

    if (all != null) {
        if (all.equals("1")) {
            this.initializeBackingTable(null, null);
            this.loc_position = 0;
            this.position_check = 0;
            this.oder_position = 0;

        }
        if (all.equals("0")) {
            if (timkiem == null && loc == null) {
                this.initializeBackingTable(sapxep, null);

            }
            if (timkiem == null && loc != null) {
                String dieukienloc;
                if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
                    dieukienloc = "DiaChi='" + loc + "'";
                } else {
                    dieukienloc = "ThonXom='" + loc + "'";
                }
                this.initializeBackingTable(sapxep, dieukienloc);
            }
            if (timkiem != null && loc == null) {
                this.initializeBackingTable(sapxep, timkiem);
            }
            if (timkiem != null && loc != null) {
                StringBuilder s = new StringBuilder();
                if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
                    s.append(timkiem).append(" and DiaChi='").append(loc).append("'");
                } else {
                    s.append(timkiem).append(" and ThonXom='").append(loc).append("'");
                }
                String dieukienloc = s.toString();
                this.initializeBackingTable(sapxep, dieukienloc);
            }
        }
    }
    if (all == null) {
        if (timten != null) {
            String timkiemten = "TenChuHo='" + timten + "'";
            if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
                timkiemten = "TenCongTrinh='" + timten + "'";
            }
            this.initializeBackingTable(null, timkiemten);
        } else {

            if (timkiem == null && loc == null) {
                this.initializeBackingTable(sapxep, null);

            }
            if (timkiem == null && loc != null) {
                String dieukienloc;
                if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
                    dieukienloc = "DiaChi='" + loc + "'";
                } else {
                    dieukienloc = "ThonXom='" + loc + "'";
                }
                this.initializeBackingTable(sapxep, dieukienloc);
            }
            if (timkiem != null && loc == null) {

                this.initializeBackingTable(sapxep, timkiem);
            }
            if (timkiem != null && loc != null) {
                StringBuilder s = new StringBuilder();
                if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
                    s.append(timkiem).append(" and DiaChi='").append(loc).append("'");
                } else {
                    s.append(timkiem).append(" and ThonXom='").append(loc).append("'");
                }
                String dieukienloc = s.toString();
                this.initializeBackingTable(sapxep, dieukienloc);
            }

        }
    }
    // this.initializeBackingTable(sapxep, timkiem);
    if (page != null) {
        if (page.toUpperCase().equals("SPREADSHEET")) {
            this.mCurrentFragmentType = ViewFragmentType.SPREADSHEET;
        }
        if (page.toUpperCase().equals("LIST")) {
            this.mCurrentFragmentType = ViewFragmentType.LIST;

        }
        if (page.toUpperCase().equals("MAP")) {
            this.mCurrentFragmentType = ViewFragmentType.MAP;
        }

    } else {
        this.mCurrentFragmentType = this.retrieveFragmentTypeToDisplay(savedInstanceState);
    }

    this.setContentView(R.layout.activity_table_display_activity);
    if (this.mCurrentFragmentType == ViewFragmentType.LIST) {
        autoComplete = (AutoCompleteTextView) findViewById(R.id.autoComplete);
        timkiemten = (LinearLayout) findViewById(R.id.timkiemten);
        timkiemten.setVisibility(View.VISIBLE);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        List<String> list = new ArrayList<String>();
        if (this.getTableId().equals("kdv_dnn_hogiadinh")) {
            list = TimTenSqlite.getTenChuHo();
        }
        if (this.getTableId().equals("kdv_vs_hogiadinh")) {
            list = TimTenSqlite.getTenChuHoVeSinh();
        }
        if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
            list = TimTenSqlite.getTenChuHoCongTrinh();
        }
        adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);

        autoComplete.setAdapter(adapter1);
        autoComplete.setThreshold(1);
        autoComplete.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                // Toast.makeText(
                // getBaseContext(),
                // "MultiAutoComplete: " + "you add color "
                // + arg0.getItemAtPosition(arg2),
                // Toast.LENGTH_LONG).show();
                String name = arg0.getItemAtPosition(arg2).toString();
                Intent intent = getIntent();
                intent.putExtra("timten", name);
                startActivity(intent);
            }
        });
    }

}

From source file:com.owncloud.android.authentication.AuthenticatorActivity.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    // TODO Auto-generated method stub

    location = parent.getItemAtPosition(position);
    Log.d("############************ ", location.toString());
    // Toast.makeText(parent.getContext(), "OnItemSelectedListener : " +
    // parent.getItemAtPosition(position).toString(),Toast.LENGTH_SHORT).show();

}

From source file:com.openatk.planting.MainActivity.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    // Spinner selected item
    Operation operation = (Operation) parent.getItemAtPosition(pos);
    if (operation.getId() == null) {
        // Create new operation
        selectCurrentOperationInSpinner(); // Go back to original for now,
        // in case cancel
        createOperation(null);//w  w  w . j a v  a 2  s  .c  o  m
    } else {
        currentOperationId = operation.getId();
        Log.d("Set HERE2", "onItemSelected - OpID:" + Integer.toString(currentOperationId));
        // Save this choice in preferences for next open
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt("currentOperationId", currentOperationId);
        editor.commit();
    }
    if (this.fragmentListView != null)
        this.fragmentListView.getData();
    drawMap();
}

From source file:com.juick.android.MessagesFragment.java

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

    LayoutInflater li = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    viewLoading = li.inflate(R.layout.listitem_loading, null);
    if (!messagesSource.canNext()) {
        viewLoading.findViewById(R.id.loadingg).setVisibility(View.GONE);
        viewLoading.findViewById(R.id.end_of_messages).setVisibility(View.VISIBLE);
        viewLoading.findViewById(R.id.progress_bar).setVisibility(View.GONE);
        viewLoading.findViewById(R.id.progress_loading_more).setVisibility(View.GONE);
    }//  w w  w . ja v  a2  s . c o  m

    mRefreshView = (RelativeLayout) li.inflate(R.layout.pull_to_refresh_header, null);
    mRefreshViewText = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
    mRefreshViewImage = (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
    mRefreshViewProgress = (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
    mRefreshViewImage.setMinimumHeight(50);
    mRefreshView.setOnClickListener(this);
    mRefreshOriginalTopPadding = mRefreshView.getPaddingTop();
    mRefreshState = TAP_TO_REFRESH;

    final ListView listView = getListView();
    listView.setBackgroundDrawable(null);
    listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    installDividerColor(listView);
    MainActivity.restyleChildrenOrWidget(listView);

    listAdapter = new JuickMessagesAdapter(getActivity(), this, JuickMessagesAdapter.TYPE_MESSAGES,
            allMessages ? JuickMessagesAdapter.SUBTYPE_ALL : JuickMessagesAdapter.SUBTYPE_OTHER);

    listAdapter.setOnForgetListener(new Utils.Function<Void, JuickMessage>() {
        @Override
        public Void apply(final JuickMessage jm) {
            Network.executeJAHTTPS(
                    getActivity(), null, JA_API_URL + "/pending?command=ignore&mid="
                            + ((JuickMessageID) jm.getMID()).getMid() + "&rid=" + jm.getRID(),
                    new Utils.Function<Void, RESTResponse>() {
                        @Override
                        public Void apply(final RESTResponse response) {
                            final Activity activity = getActivity();
                            if (activity == null)
                                return null; // gone.
                            if (response.getErrorText() != null) {
                                activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        Toast.makeText(activity, response.getErrorText(), Toast.LENGTH_SHORT)
                                                .show();
                                    }
                                });
                            } else {
                                activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        listAdapter.remove(jm);
                                        //To change body of implemented methods use File | Settings | File Templates.
                                        if (listAdapter.getCount() == 0) {
                                            if ((activity instanceof MainActivity)) {
                                                ((MainActivity) activity).doReload();
                                            }
                                        }
                                    }
                                });
                            }
                            return null;
                        }
                    });
            return null;
        }
    });
    listView.setOnTouchListener(this);
    listView.setOnScrollListener(this);
    listView.setOnItemClickListener(this);

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            if (view instanceof ImageGallery) {
                return false; // no need that! (possibly, make this condition work only if not scrolled meanwhile)
            }
            final Object itemAtPosition = parent.getItemAtPosition(position);
            if (itemAtPosition instanceof JuickMessage) {
                doOnClickActualTime = System.currentTimeMillis();
                doOnClick = new Runnable() {
                    @Override
                    public void run() {
                        JuickMessage msg = (JuickMessage) itemAtPosition;
                        MessageMenu messageMenu = MainActivity.getMicroBlog(msg).getMessageMenu(getActivity(),
                                messagesSource, listView, listAdapter);
                        if (messageMenu != null) {
                            messageMenu.onItemLongClick(parent, view, position, id);
                        } else {
                            Toast.makeText(getActivity(), "Not implemented ;-(", Toast.LENGTH_LONG).show();
                        }
                    }
                };
                if (alternativeLongClick) {
                    listView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                } else {
                    doOnClick.run();
                    doOnClick = null;
                    return true;
                }
            }
            return false;
        }
    });
    listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            System.out.println();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            System.out.println();
        }
    });
    init(false);
    if (parent != null) {
        parent.onFragmentCreated();
    }
}

From source file:com.android.calendar.event.EditEventView.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    // This is only used for the Calendar spinner in new events, and only
    // fires when the
    // calendar selection changes or on screen rotation
    Cursor c = (Cursor) parent.getItemAtPosition(position);
    if (c == null) {
        // TODO: can this happen? should we drop this check?
        Log.w(TAG, "Cursor not set on calendar item");
        return;//  w w w  .ja v  a 2  s.co  m
    }

    // Do nothing if the selection didn't change so that reminders will not
    // get lost
    int idColumn = c.getColumnIndexOrThrow(Calendars._ID);
    long calendarId = c.getLong(idColumn);
    int colorColumn = c.getColumnIndexOrThrow(Calendars.CALENDAR_COLOR);
    int color = c.getInt(colorColumn);
    int displayColor = Utils.getDisplayColorFromColor(color);

    // Prevents resetting of data (reminders, etc.) on orientation change.
    if (calendarId == mModel.mCalendarId && mModel.isCalendarColorInitialized()
            && displayColor == mModel.getCalendarColor()) {
        return;
    }

    setSpinnerBackgroundColor(displayColor);

    mModel.mCalendarId = calendarId;
    mModel.setCalendarColor(displayColor);
    mModel.mCalendarAccountName = c.getString(EditEventHelper.CALENDARS_INDEX_ACCOUNT_NAME);
    mModel.mCalendarAccountType = c.getString(EditEventHelper.CALENDARS_INDEX_ACCOUNT_TYPE);
    mModel.setEventColor(mModel.getCalendarColor());

    setColorPickerButtonStates(mModel.getCalendarEventColors());

    // Update the max/allowed reminders with the new calendar properties.
    int maxRemindersColumn = c.getColumnIndexOrThrow(Calendars.MAX_REMINDERS);
    mModel.mCalendarMaxReminders = c.getInt(maxRemindersColumn);
    int allowedRemindersColumn = c.getColumnIndexOrThrow(Calendars.ALLOWED_REMINDERS);
    mModel.mCalendarAllowedReminders = c.getString(allowedRemindersColumn);
    int allowedAttendeeTypesColumn = c.getColumnIndexOrThrow(Calendars.ALLOWED_ATTENDEE_TYPES);
    mModel.mCalendarAllowedAttendeeTypes = c.getString(allowedAttendeeTypesColumn);
    int allowedAvailabilityColumn = c.getColumnIndexOrThrow(Calendars.ALLOWED_AVAILABILITY);
    mModel.mCalendarAllowedAvailability = c.getString(allowedAvailabilityColumn);

    // Discard the current reminders and replace them with the model's
    // default reminder set.
    // We could attempt to save & restore the reminders that have been
    // added, but that's
    // probably more trouble than it's worth.
    mModel.mReminders.clear();
    mModel.mReminders.addAll(mModel.mDefaultReminders);
    mModel.mHasAlarm = mModel.mReminders.size() != 0;

    // Update the UI elements.
    mReminderItems.clear();
    LinearLayout reminderLayout = (LinearLayout) mScrollView.findViewById(R.id.reminder_items_container);
    reminderLayout.removeAllViews();
    prepareReminders();
    prepareAvailability();
}