当前位置: 首页>>代码示例>>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;未经允许,请勿转载。