当前位置: 首页>>代码示例>>Java>>正文


Java ArrayAdapter.getPosition方法代码示例

本文整理汇总了Java中android.widget.ArrayAdapter.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayAdapter.getPosition方法的具体用法?Java ArrayAdapter.getPosition怎么用?Java ArrayAdapter.getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ArrayAdapter的用法示例。


在下文中一共展示了ArrayAdapter.getPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refreshCollections

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void refreshCollections() {
	ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(findActivity(), R.layout.view_browser_spinner_item, createCollectionValues());
	arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	
	TGSelectableItem selectedItem = new TGSelectableItem(findCurrentCollection(), null);
	Integer selectedItemPosition = arrayAdapter.getPosition(selectedItem);
	
	Spinner spinner = (Spinner) this.findViewById(R.id.browser_collections);
	OnItemSelectedListener listener = spinner.getOnItemSelectedListener();
	spinner.setOnItemSelectedListener(null);
	if(!this.isSameCollection(arrayAdapter, (ArrayAdapter<TGSelectableItem>) spinner.getAdapter())) {
		spinner.setAdapter(arrayAdapter);
	}
	if( spinner.getSelectedItemPosition() != selectedItemPosition ) {
		spinner.setSelection(selectedItemPosition, false);
	}
	spinner.setOnItemSelectedListener(listener);
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:20,代码来源:TGBrowserView.java

示例2: setSpinner

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
public void setSpinner(String value, LabelledSpinner spinner) {
    if (!value.equals("-1")) {
        ArrayAdapter<CharSequence> adapter = (ArrayAdapter) spinner.getSpinner().getAdapter();
        int spinnerPosition = adapter.getPosition(value);
        spinner.setSelection(spinnerPosition);
    }
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:8,代码来源:HelloActivity.java

示例3: setBloodAdapter

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
private void setBloodAdapter() {
    final String[] choices = {"A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"};
    ArrayAdapter<String> badapter = new ArrayAdapter<String>(ProfileSetting.this, android.R.layout.simple_spinner_item, choices);
    badapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spBloodGroup.setAdapter(badapter);
    try {
        if (!bloodGroup.equals(null) && !bloodGroup.equals("0")) {
            int spinnerPosition = badapter.getPosition(bloodGroup);
            spBloodGroup.setSelection(spinnerPosition + 1);
        }
    } catch (Exception e) {
        // TODO: handle exception
    }
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:15,代码来源:ProfileSetting.java

示例4: loadPref

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
private void loadPref(SharedPreferences prefs, Spinner spinner, int id, String key, String def) {
    // temporary adapter created to get the position of an item inside the array of values
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, id, android.R.layout.simple_spinner_item);
    String selectedString = prefs.getString(key, def);
    int position = adapter.getPosition(selectedString);
    // Force the spinner to load the stored preference
    spinner.setSelection(position);
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:9,代码来源:StartActivity.java

示例5: loadPrefValue

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
private void loadPrefValue(CatchingSpinner spinner, int id, String item) {
    //Get the position of an item inside the array of values (resource id), and set as selected in the spinner
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, id, android.R.layout.simple_spinner_item);
    int position = adapter.getPosition(item);
    spinner.setSelection(position);
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:7,代码来源:ListPlayersAdapter.java

示例6: onCreateDialog

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = getActivity().getLayoutInflater();

    final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false);
    name = (AppCompatEditText) view.findViewById(R.id.name);
    host = (AppCompatEditText) view.findViewById(R.id.host);
    port = (AppCompatEditText) view.findViewById(R.id.port);
    path = (AppCompatEditText) view.findViewById(R.id.path);
    hostContainer = view.findViewById(R.id.hostContainer);
    pathContainer = view.findViewById(R.id.pathContainer);
    username = (AppCompatEditText) view.findViewById(R.id.username);
    usernameContainer = view.findViewById(R.id.usernameContainer);
    password = (AppCompatEditText) view.findViewById(R.id.password);
    passwordContainer = view.findViewById(R.id.passwordContainer);
    scheme = (AppCompatSpinner) view.findViewById(R.id.scheme);
    anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous);
    anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE);
            passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE);
        }
    });

    if(connection_id != 0){
        NetworkConnection connection =
                NetworkConnection.fromConnectionId(getActivity(), connection_id);

        ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter();
        int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase());
        scheme.setSelection(spinnerPosition);

        name.setText(connection.getName());
        host.setText(connection.getHost());
        port.setText(Integer.toString(connection.getPort()));
        path.setText(connection.getPath());
        username.setText(connection.getUserName());
        password.setText(connection.getPassword());
        anonymous.setChecked(connection.isAnonymousLogin());
        if(SERVER.equals(connection.getType())){
            hostContainer.setVisibility(View.GONE);
            pathContainer.setVisibility(View.VISIBLE);
        }
    }
    builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection");
    builder.setView(view);

    builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final BaseActivity activity = (BaseActivity) getActivity();

            NetworkConnection networkConnection = getNetworkConnection();
            if(validate(networkConnection)){
                new CreateConnectionTask(activity, networkConnection).executeOnExecutor(
                        ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY));
            }

        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:69,代码来源:CreateConnectionFragment.java

示例7: fillInData

import android.widget.ArrayAdapter; //导入方法依赖的package包/类
private void fillInData(SharedPreferences prefs) {
    //Edittext's connected to the fields in the student profile.
    EditText fullName = (EditText) findViewById(R.id.studentNameSettings);
    EditText email = (EditText) findViewById(R.id.studentEmailSettings);
    EditText major = (EditText) findViewById(R.id.studentMajorSettings);
    EditText city = (EditText) findViewById(R.id.studentCitySettings);
    EditText gradYear = (EditText) findViewById(R.id.studentGradYearSettings);
    EditText un = (EditText) findViewById(R.id.studentUsernameSettings);
    EditText pw = (EditText) findViewById(R.id.studentPasswordSettings);

    //Spinners for displaying states, and terms of graduation.
    Spinner stateSpinner = (Spinner) findViewById(R.id.stateSpinnerSettings);
    Spinner gradTermSpinner = (Spinner) findViewById(R.id.FallSpringSpinnerSettings);
    ArrayAdapter stateAdapter = (ArrayAdapter) stateSpinner.getAdapter();
    ArrayAdapter gradTermAdapter = (ArrayAdapter) gradTermSpinner.getAdapter();
    int statePos = stateAdapter.getPosition(prefs.getString("state","") );
    int gradPos = gradTermAdapter.getPosition(prefs.getString("gradTerm","") );

    //Getting data from the shared preferences to populate the student profile fields.
    fullName.setText(prefs.getString("fullName", ""));
    email.setText(prefs.getString("email",""));
    major.setText(prefs.getString("major",""));
    city.setText(prefs.getString("city",""));
    gradYear.setText(prefs.getString("gradYear",""));
    un.setText(prefs.getString("username",""));
    pw.setText(prefs.getString("password",""));
    stateSpinner.setSelection(statePos);
    gradTermSpinner.setSelection(gradPos);

    //Create new profile pic object.
    pic = new ProfilePic(null);
    ImageView profilePic = (ImageView) findViewById(R.id.thumbnailSettings);
    String imgString = prefs.getString("profilePic", "");
    //If the image string is blank, set the profile pic in the layout to the default
    //camera drawable image.
    if(imgString == "")
        profilePic.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_camera));
    //Otherwise, decode the image string, and use that bitmap for the profile pic.
    else {
        pic.setBitmap(pic.getDecodedBitmap(imgString));
        profilePic.setImageBitmap(pic.getResizedBitmap());
    }
}
 
开发者ID:umdcs,项目名称:linkedout_procon,代码行数:44,代码来源:StudentModSettings.java


注:本文中的android.widget.ArrayAdapter.getPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。