Example usage for android.widget ArrayAdapter createFromResource

List of usage examples for android.widget ArrayAdapter createFromResource

Introduction

In this page you can find the example usage for android.widget ArrayAdapter createFromResource.

Prototype

public static @NonNull ArrayAdapter<CharSequence> createFromResource(@NonNull Context context,
        @ArrayRes int textArrayResId, @LayoutRes int textViewResId) 

Source Link

Document

Creates a new ArrayAdapter from external resources.

Usage

From source file:com.teleca.jamendo.activity.RadioActivity.java

/** Called when the activity is first created. */
@SuppressWarnings("unchecked")
@Override// w w  w.ja v  a 2  s . c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.search);

    mRadioListView = (ListView) findViewById(R.id.SearchListView);
    mRadioAdapter = new RadioAdapter(this);
    mRadioListView.setAdapter(mRadioAdapter);
    mRadioListView.setOnItemClickListener(mRadioListListener);
    mButton = (Button) findViewById(R.id.SearchButton);
    mButton.setText(R.string.radio);
    mButton.setOnClickListener(mButtonClickListener);
    mEditText = (EditText) findViewById(R.id.SearchEditText);
    mViewFlipper = (ViewFlipper) findViewById(R.id.SearchViewFlipper);

    mSpinner = (Spinner) findViewById(R.id.SearchSpinner);
    ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.radio_modes,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinner.setAdapter(adapter);
    mEditText.setHint(R.string.radio_hint);

    mRadioLoadingDialog = new RadioLoadingDialog(this, R.string.loading_recomended_radios,
            R.string.failed_recomended_radios);

    mRadioLoadingDialog.execute();

    mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
            switch (position) {
            case 0:
                // recent
                mRadioAdapter.setList(new DatabaseImpl(RadioActivity.this).getRecentRadios(20));
                break;
            case 1:
                // recommended
                switch (mRadioLoadingDialog.getStatus()) {
                case RUNNING:
                    break;
                case FINISHED:
                    mRadioLoadingDialog = new RadioLoadingDialog(RadioActivity.this,
                            R.string.loading_recomended_radios, R.string.failed_recomended_radios);
                    mRadioLoadingDialog.execute();
                    break;
                case PENDING:
                    mRadioLoadingDialog.execute();
                    break;
                }
                break;

            default:
                break;
            }

            setupListView();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }

    });

    // TODO (maybe) if recent.count > 0 set to recent
    mSpinner.setSelection(1);

    mGestureOverlayView = (GestureOverlayView) findViewById(R.id.gestures);
    mGestureOverlayView
            .addOnGesturePerformedListener(JamendoApplication.getInstance().getPlayerGestureHandler());
}

From source file:com.facebook.samples.loginsample.accountkit.AccountKitLoginActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account_kit_activity);

    if (AccountKit.getCurrentAccessToken() != null) {
        showHelloActivity(null);//from w ww.  j  a v  a 2  s.  c o m
    }

    final Spinner themeSpinner = (Spinner) findViewById(R.id.theme_spinner);
    if (themeSpinner != null) {
        final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.theme_options,
                android.R.layout.simple_spinner_dropdown_item);
        themeSpinner.setAdapter(adapter);
        themeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(final AdapterView<?> parent, final View view, final int position,
                    final long id) {
                switch (position) {
                case 0:
                    selectedThemeId = R.style.AppLoginTheme;
                    break;
                case 1:
                    selectedThemeId = R.style.AppLoginTheme_Salmon;
                    break;
                case 2:
                    selectedThemeId = R.style.AppLoginTheme_Yellow;
                    break;
                case 3:
                    selectedThemeId = R.style.AppLoginTheme_Red;
                    break;
                case 4:
                    selectedThemeId = R.style.AppLoginTheme_Dog;
                    break;
                case 5:
                    selectedThemeId = R.style.AppLoginTheme_Bicycle;
                    break;
                case 6:
                    selectedThemeId = R.style.AppLoginTheme_Reverb_A;
                    advancedUISwitch.setChecked(true);
                    break;
                case 7:
                    selectedThemeId = R.style.AppLoginTheme_Reverb_B;
                    advancedUISwitch.setChecked(true);
                    break;
                case 8:
                    selectedThemeId = R.style.AppLoginTheme_Reverb_C;
                    advancedUISwitch.setChecked(true);
                    break;
                default:
                    selectedThemeId = -1;
                    break;
                }
            }

            @Override
            public void onNothingSelected(final AdapterView<?> parent) {
                selectedThemeId = -1;
            }
        });
    }

    advancedUISwitch = (Switch) findViewById(R.id.advanced_ui_switch);

    final AccountKitLoginActivity thisActivity = this;
    final LinearLayout advancedUIOptionsLayout = (LinearLayout) findViewById(R.id.advanced_ui_options);

    final List<CharSequence> buttonNames = new ArrayList<>();
    buttonNames.add("Default");
    for (ButtonType buttonType : ButtonType.values()) {
        buttonNames.add(buttonType.name());
    }
    final ArrayAdapter<CharSequence> buttonNameAdapter = new ArrayAdapter<>(thisActivity,
            android.R.layout.simple_spinner_dropdown_item, buttonNames);

    advancedUISwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                advancedUIOptionsLayout.setVisibility(View.VISIBLE);

                final Spinner entryButtonSpinner = (Spinner) findViewById(R.id.entry_button_spinner);
                if (entryButtonSpinner != null) {
                    entryButtonSpinner.setAdapter(buttonNameAdapter);
                    entryButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view,
                                final int position, final long id) {
                            // First position is empty, so anything past that
                            if (position > 0) {
                                entryButton = ButtonType
                                        .valueOf(entryButtonSpinner.getSelectedItem().toString());
                            } else {
                                entryButton = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            entryButton = null;
                        }
                    });
                }

                final Spinner confirmButtonSpinner = (Spinner) findViewById(R.id.confirm_button_spinner);
                if (confirmButtonSpinner != null) {
                    confirmButtonSpinner.setAdapter(buttonNameAdapter);
                    confirmButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view,
                                final int position, final long id) {
                            // First position is empty, so anything past
                            // that
                            if (position > 0) {
                                confirmButton = ButtonType
                                        .valueOf(confirmButtonSpinner.getSelectedItem().toString());
                            } else {
                                confirmButton = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            confirmButton = null;
                        }
                    });
                }

                final Spinner textPositionSpinner = (Spinner) findViewById(R.id.text_position_spinner);
                if (textPositionSpinner != null) {
                    final List<CharSequence> textPositions = new ArrayList<>();
                    textPositions.add("Default");
                    for (TextPosition textPosition : TextPosition.values()) {
                        textPositions.add(textPosition.name());
                    }
                    final ArrayAdapter<CharSequence> textPositionAdapter = new ArrayAdapter<>(thisActivity,
                            android.R.layout.simple_spinner_dropdown_item, textPositions);

                    textPositionSpinner.setAdapter(textPositionAdapter);
                    textPositionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view,
                                final int position, final long id) {
                            // First position is empty, so anything past
                            // that
                            if (position > 0) {
                                textPosition = TextPosition
                                        .valueOf(textPositionSpinner.getSelectedItem().toString());
                            } else {
                                textPosition = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            textPosition = null;
                        }
                    });
                }
            } else if (isReverbThemeSelected()) {
                advancedUISwitch.setChecked(true);
                Toast.makeText(AccountKitLoginActivity.this, R.string.reverb_advanced_ui_required,
                        Toast.LENGTH_LONG).show();
            } else {
                advancedUIOptionsLayout.setVisibility(View.GONE);
            }
        }
    });
}

From source file:eu.veldsoft.adsbobball.ActivityStateEnum.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);/*from   w ww .  j  av a2  s  . c om*/

    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.setOnTouchListener(this);
    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.setFormat(PixelFormat.RGB_565);
    surfaceHolder.addCallback(this);

    messageView = (TextView) findViewById(R.id.message_label);
    messageView.bringToFront();

    transparentView = findViewById(R.id.transparent_view);
    numPlayersSelector = (Spinner) findViewById(R.id.num_players);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.playerNumber,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    numPlayersSelector.setAdapter(adapter);

    button = (Button) findViewById(R.id.continue_button);
    button.setOnClickListener(this);

    statusTopleft = (TextView) findViewById(R.id.status_topleft);
    statusTopright = (TextView) findViewById(R.id.status_topright);
    statusBotleft = (TextView) findViewById(R.id.status_botleft);
    statusBotright = (TextView) findViewById(R.id.status_botright);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            onClick(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (activityState == ActivityStateEnum.GAMERUNNING)
                showPauseScreen();
        }
    });

    statusTopright.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            statusTopright.setTextColor(0xffCCCCFF);
            secretHandshake += 1;
        }
    });

    statusBotright.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (secretHandshake > 4) {
                statusBotright.setTextColor(0xffCCCCFF);
                final NetworkIP n = new NetworkIP((int) System.currentTimeMillis());
                n.startServer();
                n.clientConnect("127.0.0.1", 1234);
            }
        }
    });

    scores = new Scores(getSharedPreferences("scores", Context.MODE_PRIVATE));
    scores.loadScores();

    if (savedInstanceState == null) {
        showIntroScreen();
    }
}

From source file:ca.ualberta.cmput301.t03.inventory.AddItemView.java

/**
 * {@inheritDoc}//  w w w  . java2s. c  o  m
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_item_view);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    user = PrimaryUser.getInstance();

    Thread worker = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                inventoryModel = user.getInventory();
                itemModel = new Item();
                controller = new AddItemController(findViewById(R.id.add_item_view), activity, inventoryModel,
                        itemModel);
                itemPhotoController = new ItemPhotoController(itemModel);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ServiceNotAvailableException e) {
                throw new RuntimeException("App is offline.", e);
            }
        }
    });
    worker.start();

    // Source, accessed Nov 3, 2015
    // http://developer.android.com/guide/topics/ui/controls/spinner.html#Populate
    categoriesSpinner = (Spinner) findViewById(R.id.itemCategory);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.categories_array,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    categoriesSpinner.setAdapter(adapter);

    addToInventoryButton = (Button) findViewById(R.id.addItem);
    addToInventoryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            controller.addItemToInventory();
        }
    });

    Button uploadPhotosButton = (Button) findViewById(R.id.uploadPhotos);
    uploadPhotosButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onUploadPhotosButtonClicked();
        }
    });
}

From source file:de.ub0r.android.otpdroid.OTPdroid.java

/**
 * {@inheritDoc}//w ww  .  j av a  2 s .co m
 */
@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.main);

    this.passphrase = (EditText) this.findViewById(R.id.passphrase);
    this.hashMethod = (Spinner) this.findViewById(R.id.hash_method);
    this.sequence = (EditText) this.findViewById(R.id.sequence);
    this.challenge = (EditText) this.findViewById(R.id.challenge);
    this.response = (EditText) this.findViewById(R.id.response);

    final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.hash_methods,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(// .
            android.R.layout.simple_spinner_dropdown_item);
    this.hashMethod.setAdapter(adapter);

    if (this.imei == null || this.simid == null) {
        this.loadKeys();
    }

    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    final String v0 = settings.getString(PREFS_LAST_RUN, "");
    final String v1 = this.getString(R.string.app_version);
    if (!v0.equals(v1)) {
        final SharedPreferences.Editor editor = settings.edit();
        editor.putString(PREFS_LAST_RUN, v1);
        editor.commit();
        this.showDialog(DIALOG_UPDATE);
    }
    this.loadPassphrase(settings);

    didCalc = false;
    this.decrementSequence();
}

From source file:com.otaupdater.DownloadsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String extState = Environment.getExternalStorageState();
    if (!extState.equals(Environment.MEDIA_MOUNTED) && !extState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
        Toast.makeText(this, extState.equals(Environment.MEDIA_SHARED) ? R.string.toast_nosd_shared
                : R.string.toast_nosd_error, Toast.LENGTH_LONG).show();
        finish();//from w  w  w.j a  v a 2  s  . c o m
    }

    setContentView(R.layout.downloads);

    dlFragment = (DownloadListFragment) getFragmentManager().findFragmentById(R.id.download_list);

    Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads);
    if (adFragment != null)
        getFragmentManager().beginTransaction().hide(adFragment).commit();

    bar = getActionBar();
    assert bar != null;

    bar.setDisplayHomeAsUpEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    bar.setListNavigationCallbacks(ArrayAdapter.createFromResource(this, R.array.download_types,
            android.R.layout.simple_spinner_dropdown_item), this);

    int state = -1;
    String action = getIntent().getAction();
    if (action != null) {
        if (action.equals(FLASH_ROM_ACTION)) {
            state = GOTO_TYPE_ROM;
            showFlashDialog(RomInfo.FACTORY.fromIntent(getIntent()));
        } else if (action.equals(FLASH_KERNEL_ACTION)) {
            state = GOTO_TYPE_KERNEL;
            showFlashDialog(KernelInfo.FACTORY.fromIntent(getIntent()));
        } else {
            state = getIntent().getIntExtra(EXTRA_GOTO_TYPE, state);
        }
    }

    if (savedInstanceState != null) {
        if (state == -1)
            state = savedInstanceState.getInt("state", dlFragment.getState());
    }
    bar.setSelectedNavigationItem(state);
}

From source file:net.meiolania.apps.habrahabr.fragments.hubs.HubsMainFragment.java

private void showActionBar() {
    SherlockFragmentActivity activity = getSherlockActivity();

    ActionBar actionBar = activity.getSupportActionBar();
    actionBar.removeAllTabs();//from w  ww. j  ava  2 s  . c om
    actionBar.setTitle(R.string.hubs);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(
            activity.getSupportActionBar().getThemedContext(), R.array.hubs_list,
            R.layout.sherlock_spinner_item);
    list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
    actionBar.setListNavigationCallbacks(list, this);
}

From source file:com.mrpoid.mrplist.ui.MrplistActivity.java

private void addScreenSizeNavigation() {
    screenSizeEnties = getResources().getStringArray(R.array.screensize_entries);
    Context context = getSupportActionBar().getThemedContext();
    ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.screensize_entries,
            R.layout.sherlock_spinner_item);
    list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);

    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getSupportActionBar().setListNavigationCallbacks(list, this);

    for (int i = 0; i < screenSizeEnties.length; ++i) {
        if (screenSizeEnties[i].equals(MrpScreen.getSizeTag())) {
            getSupportActionBar().setSelectedNavigationItem(i);
            break;
        }//from   ww  w .  j av a 2 s . c  o m
    }
}

From source file:com.duongnx.ndk.examples.activities.NativeAudioActivity.java

/**
 * Called when the activity is first created.
 */// w  w  w .  ja  v a  2 s  .com
@Override
@TargetApi(17)
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.activity_native_audio);
    setTitle(Defines.NATIVE_AUDIO);
    assetManager = getAssets();

    // initialize native audio system
    createEngine();

    int sampleRate = 0;
    int bufSize = 0;
    /*
     * retrieve fast audio path sample rate and buf size; if we have it, we pass to native
     * side to create a player with fast audio enabled [ fast audio == low latency audio ];
     * IF we do not have a fast audio path, we pass 0 for sampleRate, which will force native
     * side to pick up the 8Khz sample rate.
     */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        AudioManager myAudioMgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        String nativeParam = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
        sampleRate = Integer.parseInt(nativeParam);
        nativeParam = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
        bufSize = Integer.parseInt(nativeParam);
    }
    createBufferQueueAudioPlayer(sampleRate, bufSize);

    // initialize URI spinner
    Spinner uriSpinner = (Spinner) findViewById(R.id.uri_spinner);
    ArrayAdapter<CharSequence> uriAdapter = ArrayAdapter.createFromResource(this, R.array.uri_spinner_array,
            android.R.layout.simple_spinner_item);
    uriAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    uriSpinner.setAdapter(uriAdapter);
    uriSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            URI = parent.getItemAtPosition(pos).toString();
        }

        public void onNothingSelected(AdapterView parent) {
            URI = null;
        }

    });

    // initialize button click handlers

    ((Button) findViewById(R.id.hello)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_HELLO, 5);
        }
    });

    ((Button) findViewById(R.id.android)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_ANDROID, 7);
        }
    });

    ((Button) findViewById(R.id.sawtooth)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_SAWTOOTH, 1);
        }
    });

    ((Button) findViewById(R.id.reverb)).setOnClickListener(new OnClickListener() {
        boolean enabled = false;

        public void onClick(View view) {
            enabled = !enabled;
            if (!enableReverb(enabled)) {
                enabled = !enabled;
            }
        }
    });

    ((Button) findViewById(R.id.embedded_soundtrack)).setOnClickListener(new OnClickListener() {
        boolean created = false;

        public void onClick(View view) {
            if (!created) {
                created = createAssetAudioPlayer(assetManager, "background.mp3");
            }
            if (created) {
                isPlayingAsset = !isPlayingAsset;
                setPlayingAssetAudioPlayer(isPlayingAsset);
            }
        }
    });

    // native uriPlayer is broken in android 21 and over, internal bug id: b/29321867
    // will re-open after it is fixed in later OSes
    if (Build.VERSION.SDK_INT <= 19) {
        ((Button) findViewById(R.id.uri_soundtrack)).setOnClickListener(new OnClickListener() {
            boolean created = false;

            public void onClick(View view) {
                if (!created && URI != null) {
                    created = createUriAudioPlayer(URI);
                }
            }
        });

        ((Button) findViewById(R.id.pause_uri)).setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                setPlayingUriAudioPlayer(false);
            }
        });

        ((Button) findViewById(R.id.play_uri)).setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                setPlayingUriAudioPlayer(true);
            }
        });

        ((Button) findViewById(R.id.loop_uri)).setOnClickListener(new OnClickListener() {
            boolean isLooping = false;

            public void onClick(View view) {
                isLooping = !isLooping;
                setLoopingUriAudioPlayer(isLooping);
            }
        });

        ((Button) findViewById(R.id.mute_left_uri)).setOnClickListener(new OnClickListener() {
            boolean muted = false;

            public void onClick(View view) {
                muted = !muted;
                setChannelMuteUriAudioPlayer(0, muted);
            }
        });

        ((Button) findViewById(R.id.mute_right_uri)).setOnClickListener(new OnClickListener() {
            boolean muted = false;

            public void onClick(View view) {
                muted = !muted;
                setChannelMuteUriAudioPlayer(1, muted);
            }
        });

        ((Button) findViewById(R.id.solo_left_uri)).setOnClickListener(new OnClickListener() {
            boolean soloed = false;

            public void onClick(View view) {
                soloed = !soloed;
                setChannelSoloUriAudioPlayer(0, soloed);
            }
        });

        ((Button) findViewById(R.id.solo_right_uri)).setOnClickListener(new OnClickListener() {
            boolean soloed = false;

            public void onClick(View view) {
                soloed = !soloed;
                setChannelSoloUriAudioPlayer(1, soloed);
            }
        });

        ((Button) findViewById(R.id.mute_uri)).setOnClickListener(new OnClickListener() {
            boolean muted = false;

            public void onClick(View view) {
                muted = !muted;
                setMuteUriAudioPlayer(muted);
            }
        });

        ((Button) findViewById(R.id.enable_stereo_position_uri)).setOnClickListener(new OnClickListener() {
            boolean enabled = false;

            public void onClick(View view) {
                enabled = !enabled;
                enableStereoPositionUriAudioPlayer(enabled);
            }
        });

        ((Button) findViewById(R.id.channels_uri)).setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                if (numChannelsUri == 0) {
                    numChannelsUri = getNumChannelsUriAudioPlayer();
                }
                Toast.makeText(NativeAudioActivity.this, "Channels: " + numChannelsUri, Toast.LENGTH_SHORT)
                        .show();
            }
        });

        ((SeekBar) findViewById(R.id.volume_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            int lastProgress = 100;

            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) {
                    throw new AssertionError();
                }
                lastProgress = progress;
            }

            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            public void onStopTrackingTouch(SeekBar seekBar) {
                int attenuation = 100 - lastProgress;
                int millibel = attenuation * -50;
                setVolumeUriAudioPlayer(millibel);
            }
        });

        ((SeekBar) findViewById(R.id.pan_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            int lastProgress = 100;

            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) {
                    throw new AssertionError();
                }
                lastProgress = progress;
            }

            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            public void onStopTrackingTouch(SeekBar seekBar) {
                int permille = (lastProgress - 50) * 20;
                setStereoPositionUriAudioPlayer(permille);
            }
        });
    } else {
        int[] uriIds = { R.id.uri_soundtrack, R.id.pause_uri, R.id.play_uri, R.id.loop_uri, R.id.mute_left_uri,
                R.id.mute_right_uri, R.id.solo_left_uri, R.id.solo_right_uri, R.id.mute_uri,
                R.id.enable_stereo_position_uri, R.id.channels_uri, R.id.volume_uri, R.id.pan_uri,
                R.id.uri_spinner, };
        for (int id : uriIds)
            findViewById(id).setVisibility(View.GONE);
    }

    ((Button) findViewById(R.id.record)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            int status = ActivityCompat.checkSelfPermission(NativeAudioActivity.this,
                    Manifest.permission.RECORD_AUDIO);
            if (status != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(NativeAudioActivity.this,
                        new String[] { Manifest.permission.RECORD_AUDIO }, AUDIO_ECHO_REQUEST);
                return;
            }
            recordAudio();
        }
    });

    ((Button) findViewById(R.id.playback)).setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // ignore the return value
            selectClip(CLIP_PLAYBACK, 3);
        }
    });

}

From source file:com.chriscartland.octaviastreethilton.ui.TransactionActivity.java

private void createViews() {
    mTransactionView = findViewById(R.id.transaction);

    mDateView = (TextView) findViewById(R.id.transaction_date_editor);
    mDateView.setOnClickListener(new View.OnClickListener() {
        @Override/* ww w  .  j av  a 2  s . com*/
        public void onClick(View v) {
            showDatePickerDialog(v);
        }
    });

    mPurchaserView = (Spinner) findViewById(R.id.transaction_purchaser_editor);
    mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.osh_members,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mPurchaserView.setAdapter(mSpinnerAdapter);
    mPurchaserView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String purchaser = (String) parent.getItemAtPosition(position);
            mTransactionReference.child(Transaction.KEY_PURCHASER).setValue(purchaser);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    mAmountView = (FirebaseMoneyEditText) findViewById(R.id.transaction_amount_editor);

    mDescriptionView = (FirebaseEditText) findViewById(R.id.transaction_description_editor);
    mNotesView = (FirebaseEditText) findViewById(R.id.transaction_notes_editor);
    mCartlandDebtView = (FirebaseEditText) findViewById(R.id.cartland_debt);
    mNpstanfordDebtView = (FirebaseEditText) findViewById(R.id.npstanford_debt);
    mRcrabbDebtView = (FirebaseEditText) findViewById(R.id.rcrabb_debt);
    mStrommeDebtView = (FirebaseEditText) findViewById(R.id.stromme_debt);
}