當前位置: 首頁>>代碼示例>>Java>>正文


Java Spinner.getItemAtPosition方法代碼示例

本文整理匯總了Java中android.widget.Spinner.getItemAtPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java Spinner.getItemAtPosition方法的具體用法?Java Spinner.getItemAtPosition怎麽用?Java Spinner.getItemAtPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.Spinner的用法示例。


在下文中一共展示了Spinner.getItemAtPosition方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSpinnerOptionValue

import android.widget.Spinner; //導入方法依賴的package包/類
public static void setSpinnerOptionValue(Spinner spinner, Object value) {
    for (int i = 0, count = spinner.getCount(); i < count; i++) {
        SpinnerOption so = (SpinnerOption)spinner.getItemAtPosition(i);
        if (so.value.equals(value)) {
            spinner.setSelection(i, true);
            return;
        }
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:10,代碼來源:SpinnerOption.java

示例2: setSpinnerPosition

import android.widget.Spinner; //導入方法依賴的package包/類
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
    final SpinnerAdapter adapter = spinner.getAdapter();
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final Object item = spinner.getItemAtPosition(i);
        if (item.equals(itemToSelect)) {
            spinner.setSelection(i);
            return;
        }
    }
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:12,代碼來源:CustomInputStylePreference.java

示例3: saveExitOnClick

import android.widget.Spinner; //導入方法依賴的package包/類
public void saveExitOnClick(View view){
    Intent intent = new Intent(this, ChoreListActivity.class);

    // Linking objects to XML
    EditText grabChoreName = (EditText) findViewById(R.id.choreNameInput); //Chore Name
    Spinner grabAssignedTo = findViewById(R.id.assignToSpiner); //Who the Chore is assigned to
    Spinner grabChoreType = findViewById(R.id.choreTypeSpinner); // THe type of chore
    Spinner grabPoints = findViewById(R.id.totalPointsSpinner); // The points the chore is worth
    Spinner grabResources = findViewById(R.id.requiredMaterialsSpinner); //The list of materials
    EditText grabDesc = (EditText) findViewById(R.id.descTextView2); //Description of Chore
    EditText grabNote = (EditText) findViewById(R.id.notesTextView); //Note of Chore


    //Simple variables from newChoreActivity
    //All information needed to create a chore.
    String choreName = grabChoreName.getText().toString();
    String choreAssignedTo = (String) grabAssignedTo.getSelectedItem();
    String choreType = (String) grabChoreType.getSelectedItem();
    String choreDesc = grabDesc.getText().toString();
    String choreNote = grabNote.getText().toString();
    int choreTotalPoints = Integer.parseInt((String)grabPoints.getSelectedItem());

    //FIND ALL MATERIALS THAT WERE SELECTED
    List<String> resources= new ArrayList<String>();
    for(int i = 0; i < allMaterials.size(); i++){
        StateVO currentItem = (StateVO)grabResources.getItemAtPosition(i);
        if (   currentItem.isSelected() ){
            resources.add(currentItem.getTitle());

        }
    }

    //Gets the user the chore is assigned to and the current user.
    User assignedUser = MenuActivity.getManager().getUserFromName(choreAssignedTo);

    //Administrator user
    AdminUser currentUser = MenuActivity.getManager().getAdminUserFromId(MenuActivity.getManager().getCurrentUserId());

    Chore newChore; //Chore being made.

    if (assignedUser == null || assignedUser.getUsername().equals("None")){ //UNASSIGNED CHORE

        newChore = currentUser.createUnAssignedChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType,
                dateTime.getTime(),resources , MenuActivity.getManager().nextSerialNumber() );
        MenuActivity.getManager().addUnassignedChores(newChore);
    }
    else{
        newChore = currentUser.createChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType, //If theres a User to assign
                dateTime.getTime(), resources, MenuActivity.getManager().nextSerialNumber(), assignedUser);
    }

    //Writing to database
   MenuActivity.getFbRef().child(MenuActivity.getEmail()).child("ChoreManager").setValue(MenuActivity.getManager());

    startActivity(intent);
    finish();
}
 
開發者ID:TranAlan,項目名稱:Chore-Manager-App,代碼行數:58,代碼來源:NewChoreActivity.java

示例4: saveExitOnClick

import android.widget.Spinner; //導入方法依賴的package包/類
public void saveExitOnClick(View view){
    //Clear Stack and Make MenuScreen and Go back to Chore List
    Intent mainIntent = new Intent(EditChoreActivity.this, MenuActivity.class);


    // Linking objects to XML
    EditText grabChoreName = (EditText) findViewById(R.id.choreNameInput); //Chore Name
    Spinner grabAssignedTo = findViewById(R.id.assignToSpiner); //Who the Chore is assigned to
    Spinner grabChoreType = findViewById(R.id.choreTypeSpinner); // THe type of chore
    Spinner grabPoints = findViewById(R.id.totalPointsSpinner); // The points the chore is worth
    Spinner grabResources = findViewById(R.id.requiredMaterialsSpinner); //The list of materials
    EditText grabDesc = (EditText) findViewById(R.id.descTextView2); //Description of Chore
    EditText grabNote = (EditText) findViewById(R.id.notesTextView); //Note of Chore


    //Simple variables from newChoreActivity
    String choreName = grabChoreName.getText().toString();
    String choreAssignedTo = (String) grabAssignedTo.getSelectedItem();
    String choreType = (String) grabChoreType.getSelectedItem();
    String choreDesc = grabDesc.getText().toString();
    String choreNote = grabNote.getText().toString();
    int choreTotalPoints = Integer.parseInt((String)grabPoints.getSelectedItem());

    //FIND ALL MATERIALS THAT WERE SELECTED
    List<String> resources= new ArrayList<String>();
    for(int i = 0; i < allMaterials.size(); i++){
        StateVO currentItem = (StateVO)grabResources.getItemAtPosition(i);
        if (   currentItem.isSelected() ){
            resources.add(currentItem.getTitle());

        }
    }

    Date choreDeadline = dateTime.getTime(); //Deadline
    //GETTING OLD CHORE TO CHECK IF TIME IS SAME AND TO REMOVE OLDCHORE LATER.
    Intent choreIntent = getIntent();
    Chore oldChore = (Chore) choreIntent.getSerializableExtra("ChoreInfo2");

    //Checking if User did not change chore time.
    if(formatDateTime.format(oldChore.getDeadline()).equals(actualDeadlineTextView.getText().toString())){
       choreDeadline = oldChore.getDeadline();
    }

    //Gets the user the chore is assigne to and the current user.
    User assignedUser = MenuActivity.getManager().getUserFromName(choreAssignedTo);

    //Administrator user
    AdminUser currentUser = MenuActivity.getManager().getAdminUserFromId(MenuActivity.getManager().getCurrentUserId());

    Chore newChore; //Chore thats being created

    if (assignedUser == null || assignedUser.getUsername().equals("None")){ //UNASSIGNED CHORE

        newChore = currentUser.createUnAssignedChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType,
                choreDeadline,resources , MenuActivity.getManager().nextSerialNumber() );

        MenuActivity.getManager().addUnassignedChores(newChore);
    }
    else{
        newChore = currentUser.createChore(choreName, choreDesc, choreNote, choreTotalPoints, choreType, //If theres a User to assign
                choreDeadline, resources, MenuActivity.getManager().nextSerialNumber(), assignedUser);
    }


    MenuActivity.getManager().removeChore(oldChore.getChoreId()); //Delete old chore
    MenuActivity.getFbRef().child(MenuActivity.getEmail()).child("ChoreManager").setValue(MenuActivity.getManager()); //Write to Database


    mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(mainIntent);
    Intent intent = new Intent(EditChoreActivity.this, ChoreListActivity.class);
    startActivity(intent);
    finish();

}
 
開發者ID:TranAlan,項目名稱:Chore-Manager-App,代碼行數:76,代碼來源:EditChoreActivity.java

示例5: onItemSelected

import android.widget.Spinner; //導入方法依賴的package包/類
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        Spinner timeSp = (Spinner) parent;
        String time = (String) timeSp.getItemAtPosition(position);
        showChart(time);
}
 
開發者ID:ghsxl,項目名稱:Android-Fitness,代碼行數:7,代碼來源:AnalysisActivity.java


注:本文中的android.widget.Spinner.getItemAtPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。