Example usage for android.widget Spinner setAdapter

List of usage examples for android.widget Spinner setAdapter

Introduction

In this page you can find the example usage for android.widget Spinner setAdapter.

Prototype

@Override
public void setAdapter(SpinnerAdapter adapter) 

Source Link

Document

Sets the SpinnerAdapter used to provide the data which backs this Spinner.

Usage

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display dialog to allow user to select which row to add the shortcut. For
 * TV channels let the user change the channel name.
 * /*from  ww  w . ja va 2 s  .  c  om*/
 * @see InstallShortcutReceiver
 * 
 * @param context
 * @param name
 * @param icon
 * @param uri
 */
public static void displayShortcutsRowSelection(final Launcher context, final String name, final String icon,
        final String uri) {
    if (uri == null) {
        return;
    }
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    final boolean isChannel = uri.startsWith("tv");
    dialog.setContentView(R.layout.select_row);

    final TextView channelTextView = (TextView) dialog.findViewById(R.id.channelText);
    final EditText channelNameEditText = (EditText) dialog.findViewById(R.id.channelName);
    if (isChannel) {
        channelTextView.setVisibility(View.VISIBLE);
        channelNameEditText.setVisibility(View.VISIBLE);
        channelNameEditText.setText(name);
    }

    final TextView selectTextView = (TextView) dialog.findViewById(R.id.selectText);
    selectTextView.setText(context.getString(R.string.dialog_select_row, name));

    final Spinner spinner = (Spinner) dialog.findViewById(R.id.spinner);

    final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName);
    final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio);
    currentRadioButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // hide the row name edit field if the current row radio button
            // is selected
            nameEditText.setVisibility(View.GONE);
            spinner.setVisibility(View.VISIBLE);
        }

    });
    final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio);
    newRadioButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // show the row name edit field if the new radio button is
            // selected
            nameEditText.setVisibility(View.VISIBLE);
            nameEditText.requestFocus();
            spinner.setVisibility(View.GONE);
        }

    });

    List<String> list = new ArrayList<String>();
    final ArrayList<RowInfo> rows = RowsTable.getRows(context);
    if (rows != null) {
        for (RowInfo row : rows) {
            list.add(row.getTitle());
        }
    }
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(context, R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(dataAdapter);

    Button buttonYes = (Button) dialog.findViewById(R.id.buttonOk);
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String shortcutName = name;
            try {
                if (isChannel) {
                    String channelName = channelNameEditText.getText().toString().trim();
                    if (channelName.length() == 0) {
                        channelNameEditText.requestFocus();
                        displayAlert(context, context.getString(R.string.dialog_channel_name_alert));
                        return;
                    }
                    shortcutName = channelName;
                }
                // if the new row radio button is selected, the user must
                // enter a name for the new row
                String rowName = nameEditText.getText().toString().trim();
                if (newRadioButton.isChecked() && rowName.length() == 0) {
                    nameEditText.requestFocus();
                    displayAlert(context, context.getString(R.string.dialog_new_row_name_alert));
                    return;
                }
                boolean currentRow = !newRadioButton.isChecked();
                int rowId = 0;
                int rowPosition = 0;
                if (currentRow) {
                    if (rows != null) {
                        String selectedRow = (String) spinner.getSelectedItem();
                        for (RowInfo row : rows) {
                            if (row.getTitle().equals(selectedRow)) {
                                rowId = row.getId();
                                ArrayList<ItemInfo> items = ItemsTable.getItems(context, rowId);
                                rowPosition = items.size(); // in last
                                // position
                                // for selected
                                // row
                                break;
                            }
                        }
                    }
                } else {
                    rowId = (int) RowsTable.insertRow(context, rowName, 0, RowInfo.FAVORITE_TYPE);
                    rowPosition = 0;
                }

                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(uri));
                ItemsTable.insertItem(context, rowId, rowPosition, shortcutName, intent, icon,
                        DatabaseHelper.SHORTCUT_TYPE);
                Toast.makeText(context, context.getString(R.string.shortcut_installed, shortcutName),
                        Toast.LENGTH_SHORT).show();
                context.reloadAllGalleries();

                if (currentRow) {
                    Analytics.logEvent(Analytics.ADD_SHORTCUT);
                } else {
                    Analytics.logEvent(Analytics.ADD_SHORTCUT_WITH_ROW);
                }

            } catch (Exception e) {
                Log.d(LOG_TAG, "onClick", e);
            }

            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.buttonCancel);
    buttonNo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_ADD_SHORTCUT);
}

From source file:hu.fnf.devel.atlas.Atlas.java

private void changeViewLevel(int evelId, int pageId, int amountOrId) {

    setContentView(evelId);/*from  w  ww . ja  v a  2 s. c o  m*/
    AtlasData.pushPos(AtlasData.DETAILS, pageId);
    switch (evelId) {
    case R.layout.detail_view:
        TextView id = (TextView) findViewById(R.id.id);
        TextView tag = (TextView) findViewById(R.id.tag);
        if (amountOrId >= 0) {
            id.setText(String.valueOf(amountOrId));
        } else {
            id.setText(String.valueOf(amountOrId));
            tag.setText("MANUAL");
        }

        ContentResolver cr = getContentResolver();
        /*
         * load categories
         */
        Uri.Builder builder = new Builder();
        builder.scheme("content");
        builder.authority(AtlasData.DB_AUTHORITY);
        builder.appendPath(AtlasData.TABLE_CATEGORIES);
        builder.appendPath("all");

        Cursor item = cr.query(builder.build(), AtlasData.CATEGORIES_COLUMNS, null, null, null);

        if (item != null && item.moveToFirst()) {
            do {
                Category c = new Category(item.getString(AtlasData.CATEGORIES_ID),
                        item.getString(AtlasData.CATEGORIES_NAME), item.getString(AtlasData.CATEGORIES_AMOUNT),
                        item.getString(AtlasData.CATEGORIES_DEPTH), item.getString(AtlasData.CATEGORIES_COLORR),
                        item.getString(AtlasData.CATEGORIES_COLORG),
                        item.getString(AtlasData.CATEGORIES_COLORB));
                categories.put(c.getName(), c);
            } while (item.moveToNext());
            item.close();
        }

        /*
         * transaction details
         */
        TextView amountText = (TextView) findViewById(R.id.taskAmount);
        TextView fromText = (TextView) findViewById(R.id.taskFrom);
        TextView toText = (TextView) findViewById(R.id.taskTo);
        TextView dateText = (TextView) findViewById(R.id.taskDate);

        ListView cats = (ListView) findViewById(R.id.taskCats);
        ArrayList<Category> cat_list = new ArrayList<Category>();
        CatAddAdapter cat_adapter = new CatAddAdapter(getApplicationContext(), R.layout.addcat_view, cat_list);

        if (amountOrId >= 0) {
            builder = new Builder();
            builder.scheme("content");
            builder.authority(AtlasData.DB_AUTHORITY);
            builder.appendPath(AtlasData.TABLE_TRANSACTIONS);
            builder.appendPath("tasks");
            builder.appendPath(String.valueOf(amountOrId));

            item = cr.query(builder.build(), AtlasData.TRANSACTIONS_COLUMNS, null, null, null);

            if (item.moveToFirst()) {
                switch (item.getInt(AtlasData.TRANSACTIONS_TYPEID)) {
                case AtlasData.CARD_PAYMENT:
                    tag.setText(item.getString(AtlasData.TRANSACTIONS_TO));
                    break;
                case AtlasData.CARD_CASHWITHDRAWAL:
                    tag.setText(item.getString(AtlasData.TRANSACTIONS_TO));
                    break;
                case AtlasData.TRANSFER_INCOME:
                    tag.setText(item.getString(AtlasData.TRANSACTIONS_FROM));
                    break;
                case AtlasData.TRANSFER_OUTCOME:
                    tag.setText(item.getString(AtlasData.TRANSACTIONS_TO));
                    break;
                case AtlasData.TRANSFER_REPEATING:
                    tag.setText(item.getString(AtlasData.TRANSACTIONS_TO));
                    break;
                }
                amountText.setText(item.getString(AtlasData.TRANSACTIONS_AMOUNT));
                fromText.setText(item.getString(AtlasData.TRANSACTIONS_FROM));
                toText.setText(item.getString(AtlasData.TRANSACTIONS_TO));
                dateText.setText(AtlasData.getStringDateFromInt(item.getInt(AtlasData.TRANSACTIONS_DATE)));

                cat_adapter.setAmount(item.getDouble(AtlasData.TRANSACTIONS_AMOUNT));
            } else {
                Log.e("Atlas", "cannot load data for view!");
                return;
            }
            item.close();
        } else {
            Calendar cal = new GregorianCalendar(TimeZone.getDefault());

            dateText.setText(AtlasData.getStringDateFromInt((int) (cal.getTimeInMillis() / 1000L)));
            double amount = amountOrId * -1;
            amountText.setText(String.valueOf(amount));
            cat_adapter.setAmount(amount);
        }
        cats.setAdapter(cat_adapter);
        Spinner spinner = (Spinner) findViewById(R.id.taskSpinner);

        builder = new Builder();
        builder.scheme("content");
        builder.authority(AtlasData.DB_AUTHORITY);
        builder.appendPath(AtlasData.TABLE_CATEGORIES);
        builder.appendPath("tip");
        builder.appendQueryParameter(AtlasData.DATA_COLUMNS[AtlasData.DATA_TAG], String.valueOf(tag.getText()));

        item = cr.query(builder.build(), AtlasData.CATEGORIES_COLUMNS, null, null, null);

        ArrayList<String> array_spinner = new ArrayList<String>();

        if (item.moveToFirst()) {
            do {
                array_spinner.add(item.getString(AtlasData.CATEGORIES_NAME));
            } while (item.moveToNext());
        }
        ArrayAdapter<String> arrayadapter = new ArrayAdapter<String>(getApplicationContext(),
                R.layout.custom_simple_spinner, array_spinner);
        spinner.setAdapter(arrayadapter);
        item.close();
        break;
    default:
        break;
    }
    Log.d("Atlas", "changeViewLevel to " + AtlasData.DETAILS + " : " + pageId);
    pager.setCurrentItem(pageId);
    setPagerSwipeActions();
}

From source file:net.phase.wallet.Currency.java

protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
    case DIALOG_URL:
        TextView tv = (TextView) dialog.findViewById(R.id.pasteBinHelpText);
        tv.setMovementMethod(LinkMovementMethod.getInstance());

        break;//from  w ww  .  j  ava2 s  . co m
    case DIALOG_FILE:
        TextView tvhelp = (TextView) dialog.findViewById(R.id.helpText);
        tvhelp.setMovementMethod(LinkMovementMethod.getInstance());

        Spinner fileSpinner = (Spinner) dialog.findViewById(R.id.fileInput);

        File[] files = Environment.getExternalStorageDirectory().listFiles(fileFilter);

        if (files == null || files.length == 0) {
            toastMessage("No files found on sdcard");
        } else {
            ArrayAdapter<File> adapter = new ArrayAdapter<File>(this, android.R.layout.simple_spinner_item,
                    files);
            fileSpinner.setAdapter(adapter);
        }
        break;
    case DIALOG_PASTE:
        EditText keyText = (EditText) dialog.findViewById(R.id.keysText);

        keyText.setText("");
        break;
    case DIALOG_OPTIONS:
        EditText reqText = (EditText) dialog.findViewById(R.id.reqText);

        reqText.setText(Integer.toString(maxlength));
        Spinner currencySpinner = (Spinner) dialog.findViewById(R.id.currencySpinner);
        Spinner decimalSpinner = (Spinner) dialog.findViewById(R.id.decpointSpinner);

        String current = getActiveCurrency();
        String[] currencies = { current };

        try {
            currencies = Currency.getAvailableCurrencies();
        } catch (IOException e) {
            WalletActivity.toastMessage("Warning: unable to obtain currency information");
        } catch (JSONException e) {
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
                currencies);
        currencySpinner.setAdapter(adapter);
        for (int i = 0; i < currencies.length; i++) {
            if (currencies[i].equals(current)) {
                currencySpinner.setSelection(i);
                break;
            }
        }

        Integer[] decimaloptions = { 0, 1, 2, 3, 4, 5 };

        ArrayAdapter<Integer> adapter2 = new ArrayAdapter<Integer>(this, android.R.layout.simple_spinner_item,
                decimaloptions);
        decimalSpinner.setAdapter(adapter2);
        for (int i = 0; i < decimaloptions.length; i++) {
            if (decimaloptions[i].intValue() == decimalpoints) {
                decimalSpinner.setSelection(i);
                break;
            }
        }

        break;
    }
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java

final static private void setSpinnerCompareType(final GlobalParameters mGlblParms, Dialog dialog,
        Spinner spinner, CustomSpinnerAdapter adapter, String selected, boolean c_eq, boolean c_ne,
        boolean c_gt, boolean c_lt, boolean c_bw) {
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_action_compare_select_type));
    spinner.setAdapter(adapter);
    adapter.clear();//  w  w w.  j  a  va  2 s.  co m
    if (c_eq)
        adapter.add(PROFILE_ACTION_TYPE_COMPARE_COMPARE_EQ);
    if (c_ne)
        adapter.add(PROFILE_ACTION_TYPE_COMPARE_CPMPARE_NE);
    if (c_gt)
        adapter.add(PROFILE_ACTION_TYPE_COMPARE_COMPARE_GT);
    if (c_lt)
        adapter.add(PROFILE_ACTION_TYPE_COMPARE_COMPARE_LT);
    if (c_bw)
        adapter.add(PROFILE_ACTION_TYPE_COMPARE_COMPARE_BETWEEN);
    for (int i = 0; i < adapter.getCount(); i++)
        if (adapter.getItem(i).equals(selected)) {
            spinner.setSelection(i);
            break;
        }
}

From source file:ca.mimic.apphangar.Settings.java

protected void setUpSpinner(Spinner spinner) {
    String[] spinnerItems = getResources().getStringArray(R.array.entries_action_spinner);
    List<SparseArray<String>> items = new ArrayList<SparseArray<String>>();
    for (int i = 0; i < spinnerItems.length; i++) {
        SparseArray<String> spinnerMap = new SparseArray<String>();
        spinnerMap.put(i, spinnerItems[i]);
        items.add(spinnerMap);//from   w ww . ja  va  2s.  co  m
    }
    final List<SparseArray<String>> finalItems = items;

    SpinnerAdapter mSpinnerAdapter = new CustomArrayAdapter(mContext,
            android.R.layout.simple_spinner_dropdown_item, items);
    spinner.setAdapter(mSpinnerAdapter);

    Spinner.OnItemSelectedListener spinnerListener = new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            try {
                ((TextView) view).setText(finalItems.get(i).get(i));
            } catch (NullPointerException e) {
            }
            switch (i) {
            case 0:
                return;
            case 1:
                startActivity(new Intent(mContext, AppsWidgetSettings.class));
                break;
            case 2:
                startActivity(new Intent(mContext, StatsWidgetSettings.class));
                break;
            }
        }

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

    spinner.setAdapter(mSpinnerAdapter);
    spinner.setOnItemSelectedListener(spinnerListener);
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    // Remove flag button if a single bot app.
    if (MainActivity.launchType == LaunchType.Bot) {
        //findViewById(R.id.flagButton).setVisibility(View.GONE);
    }//from w ww  .j a va 2 s  . com

    //permission required.
    ActivityCompat.requestPermissions(ChatActivity.this, new String[] { Manifest.permission.RECORD_AUDIO }, 1);

    //set/Save the current volume from the device.
    setStreamVolume();
    //Music Volume is Enabled.
    muteMicBeep(false);

    //For "scream" issue
    micLastStat = MainActivity.listenInBackground;

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    this.instance = (InstanceConfig) MainActivity.instance;
    if (this.instance == null) {
        return;
    }
    /*if (MainActivity.showAds) {
         AdView mAdView = (AdView) findViewById(R.id.adView);
         AdRequest adRequest = new AdRequest.Builder().build();
         mAdView.loadAd(adRequest);
    } else {
       AdView mAdView = (AdView) findViewById(R.id.adView);
       mAdView.setVisibility(View.GONE);
    }*/

    setTitle(this.instance.name);
    ((TextView) findViewById(R.id.title)).setText(this.instance.name);
    HttpGetImageAction.fetchImage(this, this.instance.avatar, findViewById(R.id.icon));
    ttsInit = false;
    tts = new TextToSpeech(this, this);

    if (!MainActivity.handsFreeSpeech) {
        setMicIcon(false, false);
    } else if (!MainActivity.listenInBackground) {
        setMicIcon(false, false);
    }

    //Last time will be saved for the MIC.
    if (MainActivity.listenInBackground && MainActivity.handsFreeSpeech) {
        microphoneThread(thread);
    }

    speech = SpeechRecognizer.createSpeechRecognizer(this);
    speech.setRecognitionListener(this);
    //scrollVie added and stuff
    scrollView = findViewById(R.id.chatList);
    menuMLayout = (LinearLayout) findViewById(R.id.menuMLayout);
    chatCLayout = (LinearLayout) findViewById(R.id.chatCLayout);
    responseLayout = (LinearLayout) findViewById(R.id.responseLayout);
    chatToolBar = (LinearLayout) findViewById(R.id.chatToolBar);

    videoView = (VideoView) findViewById(R.id.videoView);
    resetVideoErrorListener();
    videoError = false;

    imageView = (ImageView) findViewById(R.id.imageView);
    videoLayout = findViewById(R.id.videoLayout);

    textView = (EditText) findViewById(R.id.messageText);
    textView.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            submitChat();
            return false;
        }
    });

    if (MainActivity.translate) {
        findViewById(R.id.yandex).setVisibility(View.VISIBLE);
    } else {
        findViewById(R.id.yandex).setVisibility(View.GONE);
    }

    Spinner emoteSpin = (Spinner) findViewById(R.id.emoteSpin);
    emoteSpin.setAdapter(
            new EmoteSpinAdapter(this, R.layout.emote_list, Arrays.asList(EmotionalState.values())));

    ListView list = (ListView) findViewById(R.id.chatList);
    list.setAdapter(new ChatListAdapter(this, R.layout.chat_list, this.messages));
    list.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

    ImageButton button = (ImageButton) findViewById(R.id.speakButton);
    button.setOnClickListener(new View.OnClickListener() {
        @TargetApi(23)
        @Override
        public void onClick(View v) {
            if (MainActivity.handsFreeSpeech) {
                //set the current volume to the setting.
                setStreamVolume();
                //if its ON Or OFF - Switching back and forth 
                MainActivity.listenInBackground = !MainActivity.listenInBackground;

                //saving the boolean data of MainActivity.listeningInBackground
                SharedPreferences.Editor cookies = MainActivity.current.getPreferences(Context.MODE_PRIVATE)
                        .edit();
                cookies.putBoolean("listenInBackground", MainActivity.listenInBackground);
                cookies.commit();
                if (MainActivity.listenInBackground) {
                    micLastStat = true;
                    try {
                        microphoneThread(thread);
                    } catch (Exception ignore) {
                    }
                    beginListening();
                } else {
                    micLastStat = false;
                    microphoneThread(thread);
                    stopListening();
                }
            } else {
                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, MainActivity.voice.language);
                try {
                    startActivityForResult(intent, RESULT_SPEECH);
                    textView.setText("");
                } catch (ActivityNotFoundException a) {
                    Toast t = Toast.makeText(getApplicationContext(),
                            "Your device doesn't support Speech to Text", Toast.LENGTH_SHORT);
                    t.show();
                }
            }
        }
    });

    //adding functionality on clicking the image  
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (stateLayouts == 4) {
                stateLayouts = 0;
            }
            switch (stateLayouts) {
            case 0:
                scrollView.setVisibility(View.VISIBLE);
                chatCLayout.setVisibility(View.VISIBLE);
                menuMLayout.setVisibility(View.VISIBLE);
                responseLayout.setVisibility(View.VISIBLE);
                chatToolBar.setVisibility(View.VISIBLE);
                break;
            case 1:
                scrollView.setVisibility(View.GONE);
                break;
            case 2:
                responseLayout.setVisibility(View.GONE);
                chatToolBar.setVisibility(View.GONE);
                break;
            case 3:
                menuMLayout.setVisibility(View.GONE);
                chatCLayout.setVisibility(View.GONE);
                break;
            }
            stateLayouts++;
        }
    });

    //adding functionality on clicking the image 
    videoLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (stateLayouts == 4) {
                stateLayouts = 0;
            }
            switch (stateLayouts) {
            case 0:
                scrollView.setVisibility(View.VISIBLE);
                chatCLayout.setVisibility(View.VISIBLE);
                menuMLayout.setVisibility(View.VISIBLE);
                responseLayout.setVisibility(View.VISIBLE);
                chatToolBar.setVisibility(View.VISIBLE);
                break;
            case 1:
                scrollView.setVisibility(View.GONE);
                break;
            case 2:
                responseLayout.setVisibility(View.GONE);
                chatToolBar.setVisibility(View.GONE);
                break;
            case 3:
                menuMLayout.setVisibility(View.GONE);
                chatCLayout.setVisibility(View.GONE);
                break;
            }
            stateLayouts++;
        }
    });

    GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTapEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                boolean isVideo = !MainActivity.disableVideo && !videoError && response != null
                        && response.isVideo();
                View imageView = findViewById(R.id.imageView);
                View videoLayout = findViewById(R.id.videoLayout);
                if (imageView.getVisibility() == View.VISIBLE) {
                    imageView.setVisibility(View.GONE);
                } else if (!isVideo) {
                    imageView.setVisibility(View.VISIBLE);
                }
                if (videoLayout.getVisibility() == View.VISIBLE) {
                    videoLayout.setVisibility(View.GONE);
                } else if (isVideo) {
                    videoLayout.setVisibility(View.VISIBLE);
                }
                return true;
            }
            return false;
        }
    };
    final GestureDetector detector = new GestureDetector(this, listener);
    findViewById(R.id.chatList).setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return detector.onTouchEvent(event);
        }
    });

    listener = new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTapEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                View avatarLayout = findViewById(R.id.avatarLayout);
                if (avatarLayout.getVisibility() == View.VISIBLE) {
                    avatarLayout.setVisibility(View.GONE);
                } else {
                    avatarLayout.setVisibility(View.VISIBLE);
                }
                return true;
            }
            return false;
        }
    };
    final GestureDetector detector2 = new GestureDetector(this, listener);
    /*findViewById(R.id.responseText).setOnTouchListener(new View.OnTouchListener() {         
       @Override
       public boolean onTouch(View v, MotionEvent event) {
    return detector2.onTouchEvent(event);
       }
    });*/
    WebView responseView = (WebView) findViewById(R.id.responseText);
    responseView.getSettings().setJavaScriptEnabled(true);
    responseView.getSettings().setDomStorageEnabled(true);
    responseView.addJavascriptInterface(new WebAppInterface(this), "Android");

    findViewById(R.id.responseImageView).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            View avatarLayout = findViewById(R.id.avatarLayout);
            if (avatarLayout.getVisibility() == View.VISIBLE) {
                avatarLayout.setVisibility(View.GONE);
            } else {
                avatarLayout.setVisibility(View.VISIBLE);
            }
        }
    });

    HttpGetImageAction.fetchImage(this, instance.avatar, this.imageView);
    HttpGetImageAction.fetchImage(this, instance.avatar, (ImageView) findViewById(R.id.responseImageView));

    final ChatConfig config = new ChatConfig();
    config.instance = instance.id;
    config.avatar = this.avatarId;
    if (MainActivity.translate && MainActivity.voice != null) {
        config.language = MainActivity.voice.language;
    }
    if (MainActivity.disableVideo) {
        config.avatarFormat = "image";
    } else {
        config.avatarFormat = MainActivity.webm ? "webm" : "mp4";
    }
    config.avatarHD = MainActivity.hd;
    config.speak = !MainActivity.deviceVoice;
    // This is required because of a bug in TextToSpeech that prevents onInit being called if an AsynchTask is called...
    Thread thread1 = new Thread() {
        public void run() {
            for (int count = 0; count < 5; count++) {
                if (ttsInit) {
                    break;
                }
                try {
                    Thread.sleep(1000);
                } catch (Exception exception) {
                }
            }
            HttpAction action = new HttpChatAction(ChatActivity.this, config);
            action.execute();
        }
    };
    thread1.start();
}

From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java

private void initShootModeSpinner() {

    // TODO: define the text and the icons in an enum, to ensure that they have the same order.
    // Spinner for shoot mode:
    Spinner shootModeSpinner = (Spinner) findViewById(R.id.shoot_mode_spinner);
    String[] shootModeText = getResources().getStringArray(R.array.shoot_mode_array);
    Integer[] shootModeIcons = new Integer[] { R.drawable.ic_photo_vector, R.drawable.ic_burst_mode_vector };
    shootModeSpinner
            .setAdapter(new ShootModeAdapter(this, R.layout.spinner_row, shootModeText, shootModeIcons));
    shootModeSpinner.setOnItemSelectedListener(this);

    //        Used to prevent firing the onItemSelected method:
    mItemSelectedAutomatically = true;//from  w w w. j a va 2 s .  c o  m
    if (mIsSeriesMode)
        shootModeSpinner.setSelection(SERIES_POS);

}

From source file:com.npi.muzeiflickr.ui.activities.SettingsActivity.java

private void populateFooter(View footerView) {
    final View footerButton = footerView.findViewById(R.id.list_footer_button);
    final Spinner footerModeChooser = (Spinner) footerView.findViewById(R.id.mode_chooser);
    final RelativeLayout addItemContainer = (RelativeLayout) footerView.findViewById(R.id.new_item_container);
    final ImageButton footerSearchButton = (ImageButton) footerView.findViewById(R.id.footer_search_button);
    final ProgressBar footerProgress = (ProgressBar) footerView.findViewById(R.id.footer_progress);
    final EditText footerTerm = (EditText) footerView.findViewById(R.id.footer_term);

    footerButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override/*from  w ww .ja v  a2 s .  c om*/
        public boolean onLongClick(View v) {
            int[] pos = new int[2];
            footerButton.getLocationInWindow(pos);

            String contentDesc = footerButton.getContentDescription().toString();
            Toast t = Toast.makeText(SettingsActivity.this, contentDesc, Toast.LENGTH_SHORT);
            t.show();
            t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, pos[1] + (footerButton.getHeight() / 2));

            return true;
        }
    });

    footerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addItemContainer.animate().alpha(1F);
            footerButton.animate().alpha(0F);
        }
    });

    //Mode spinner management
    ArrayAdapter<CharSequence> adapter = new SourceSpinnerAdapter(this, android.R.layout.simple_spinner_item,
            getResources().getStringArray(R.array.modes));

    footerModeChooser.setAdapter(adapter);

    footerSearchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String searchString = footerTerm.getText().toString();
            switch (footerModeChooser.getSelectedItemPosition()) {
            case 0:

                //It's a search

                //Looking for a same existing search
                List<Search> searchs = Search.listAll(Search.class);
                for (Search search : searchs) {
                    if (search.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.search_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getSearch(searchString, new UserInfoListener<Search>() {
                    @Override
                    public void onSuccess(Search search) {
                        mRequestAdapter.add(search);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });

                break;
            case 1:
                //It's an user

                //Looking for a same existing search
                List<User> users = User.listAll(User.class);
                for (User user : users) {
                    if (user.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.user_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getUserId(searchString, new UserInfoListener<User>() {
                    @Override
                    public void onSuccess(User user) {
                        mRequestAdapter.add(user);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });
                break;
            case 2:
                //It's a tag

                //Looking for a same existing search
                List<Tag> tags = Tag.listAll(Tag.class);
                for (Tag tag : tags) {
                    if (tag.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.user_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getTag(searchString, new UserInfoListener<Tag>() {
                    @Override
                    public void onSuccess(Tag tag) {
                        mRequestAdapter.add(tag);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });
                break;

            case 3:
                //It's an user

                //Looking for a same existing search
                List<FGroup> groups = FGroup.listAll(FGroup.class);
                for (FGroup group : groups) {
                    if (group.getTitle().equals(searchString)) {
                        Toast.makeText(SettingsActivity.this, getString(R.string.group_exists),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                }

                footerSearchButton.setVisibility(View.GONE);
                footerProgress.setVisibility(View.VISIBLE);

                getGroupId(searchString, new UserInfoListener<FGroup>() {
                    @Override
                    public void onSuccess(FGroup group) {
                        mRequestAdapter.add(group);
                        mRequestAdapter.notifyDataSetChanged();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                        footerTerm.setText("");
                        footerModeChooser.setSelection(0);
                        addItemContainer.animate().alpha(0F);
                        footerButton.animate().alpha(1F);
                    }

                    @Override
                    public void onError(String reason) {
                        Toast.makeText(SettingsActivity.this, reason, Toast.LENGTH_LONG).show();
                        footerSearchButton.setVisibility(View.VISIBLE);
                        footerProgress.setVisibility(View.GONE);
                    }
                });
                break;
            }
        }
    });
}

From source file:com.cypress.cysmart.BLEServiceFragments.SensorHubService.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.sensor_hub, container, false);
    LinearLayout parent = (LinearLayout) rootView.findViewById(R.id.parent_sensorhub);
    parent.setOnClickListener(new OnClickListener() {

        @Override//w w w  .  ja va 2  s.co m
        public void onClick(View v) {

        }
    });
    accX = (TextView) rootView.findViewById(R.id.acc_x_value);
    accY = (TextView) rootView.findViewById(R.id.acc_y_value);
    accZ = (TextView) rootView.findViewById(R.id.acc_z_value);
    BAT = (TextView) rootView.findViewById(R.id.bat_value);
    STEMP = (TextView) rootView.findViewById(R.id.temp_value);
    mProgressDialog = new ProgressDialog(getActivity());
    Spressure = (TextView) rootView.findViewById(R.id.pressure_value);

    // Locate device button listener
    Button locateDevice = (Button) rootView.findViewById(R.id.locate_device);
    locateDevice.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Button btn = (Button) v;
            String buttonText = btn.getText().toString();
            String startText = getResources().getString(R.string.sen_hub_locate);
            String stopText = getResources().getString(R.string.sen_hub_locate_stop);
            if (buttonText.equalsIgnoreCase(startText)) {
                btn.setText(stopText);
                if (mWriteAlertCharacteristic != null) {
                    byte[] convertedBytes = convertingTobyteArray(IMM_HIGH_ALERT);
                    BluetoothLeService.writeCharacteristicNoresponse(mWriteAlertCharacteristic, convertedBytes);
                }

            } else {
                btn.setText(startText);
                if (mWriteAlertCharacteristic != null) {
                    byte[] convertedBytes = convertingTobyteArray(IMM_NO_ALERT);
                    BluetoothLeService.writeCharacteristicNoresponse(mWriteAlertCharacteristic, convertedBytes);
                }
            }

        }
    });
    final ImageButton acc_more = (ImageButton) rootView.findViewById(R.id.acc_more);
    final ImageButton stemp_more = (ImageButton) rootView.findViewById(R.id.stemp_more);
    final ImageButton spressure_more = (ImageButton) rootView.findViewById(R.id.spressure_more);

    final LinearLayout acc_layLayout = (LinearLayout) rootView.findViewById(R.id.acc_context_menu);
    final LinearLayout stemp_layLayout = (LinearLayout) rootView.findViewById(R.id.stemp_context_menu);
    final LinearLayout spressure_layLayout = (LinearLayout) rootView.findViewById(R.id.spressure_context_menu);

    // expand listener
    acc_more.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (acc_layLayout.getVisibility() != View.VISIBLE) {
                acc_more.setRotation(90);
                CustomSlideAnimation a = new CustomSlideAnimation(acc_layLayout, CustomSlideAnimation.EXPAND);
                a.setHeight(height);
                acc_layLayout.startAnimation(a);
                acc_scan_interval = (EditText) rootView.findViewById(R.id.acc_sensor_scan_interval);
                if (ACCSensorScanCharacteristic != null) {
                    acc_scan_interval.setText(ACCSensorScanCharacteristic);
                }
                acc_sensortype = (TextView) rootView.findViewById(R.id.acc_sensor_type);
                if (ACCSensorTypeCharacteristic != null) {
                    acc_sensortype.setText(ACCSensorTypeCharacteristic);
                }
                acc_scan_interval.setOnEditorActionListener(new OnEditorActionListener() {

                    @Override
                    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                        if (actionId == EditorInfo.IME_ACTION_DONE) {
                            int myNum = 0;

                            try {
                                myNum = Integer.parseInt(acc_scan_interval.getText().toString());
                            } catch (NumberFormatException nfe) {
                                nfe.printStackTrace();
                            }
                            byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum));
                            BluetoothLeService.writeCharacteristicNoresponse(mReadACCSensorScanCharacteristic,
                                    convertedBytes);
                        }
                        return false;
                    }
                });
                Spinner spinner_filterconfiguration = (Spinner) rootView
                        .findViewById(R.id.acc_filter_configuration);
                // Create an ArrayAdapter using the string array and a
                // default
                // spinner layout
                ArrayAdapter<CharSequence> adapter_filterconfiguration = ArrayAdapter.createFromResource(
                        getActivity(), R.array.filter_configuration_alert_array,
                        android.R.layout.simple_spinner_item);
                // Specify the layout to use when the list of choices
                // appears
                adapter_filterconfiguration
                        .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                // Apply the adapter to the spinner
                spinner_filterconfiguration.setAdapter(adapter_filterconfiguration);

            } else {
                acc_more.setRotation(-90);

                acc_scan_interval.setText("");
                acc_sensortype.setText("");
                CustomSlideAnimation a = new CustomSlideAnimation(acc_layLayout, CustomSlideAnimation.COLLAPSE);
                height = a.getHeight();
                acc_layLayout.startAnimation(a);
            }
        }
    });
    // expand listener
    stemp_more.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (stemp_layLayout.getVisibility() != View.VISIBLE) {
                stemp_more.setRotation(90);
                CustomSlideAnimation a = new CustomSlideAnimation(stemp_layLayout, CustomSlideAnimation.EXPAND);
                a.setHeight(height);
                stemp_layLayout.startAnimation(a);
                stemp_scan_interval = (EditText) rootView.findViewById(R.id.stemp_sensor_scan_interval);
                if (STEMPSensorScanCharacteristic != null) {
                    stemp_scan_interval.setText(STEMPSensorScanCharacteristic);
                }
                stemp_sensortype = (TextView) rootView.findViewById(R.id.stemp_sensor_type);
                if (STEMPSensorTypeCharacteristic != null) {
                    stemp_sensortype.setText(STEMPSensorTypeCharacteristic);
                }
                stemp_scan_interval.setOnEditorActionListener(new OnEditorActionListener() {

                    @Override
                    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                        if (actionId == EditorInfo.IME_ACTION_DONE) {
                            int myNum = 0;

                            try {
                                myNum = Integer.parseInt(stemp_scan_interval.getText().toString());
                            } catch (NumberFormatException nfe) {
                                nfe.printStackTrace();
                            }
                            byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum));
                            BluetoothLeService.writeCharacteristicNoresponse(mReadSTEMPSensorScanCharacteristic,
                                    convertedBytes);
                        }
                        return false;
                    }
                });

            } else {
                stemp_more.setRotation(-90);
                stemp_scan_interval.setText("");
                stemp_sensortype.setText("");
                CustomSlideAnimation a = new CustomSlideAnimation(stemp_layLayout,
                        CustomSlideAnimation.COLLAPSE);
                height = a.getHeight();
                stemp_layLayout.startAnimation(a);
            }
        }
    });
    // expand listener
    spressure_more.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (spressure_layLayout.getVisibility() != View.VISIBLE) {
                spressure_more.setRotation(90);
                CustomSlideAnimation a = new CustomSlideAnimation(spressure_layLayout,
                        CustomSlideAnimation.EXPAND);
                a.setHeight(height);
                spressure_layLayout.startAnimation(a);
                spressure_scan_interval = (EditText) rootView.findViewById(R.id.spressure_sensor_scan_interval);
                if (SPRESSURESensorScanCharacteristic != null) {
                    spressure_scan_interval.setText(SPRESSURESensorScanCharacteristic);
                }
                spressure_sensortype = (TextView) rootView.findViewById(R.id.spressure_sensor_type);
                if (SPRESSURESensorTypeCharacteristic != null) {
                    spressure_sensortype.setText(SPRESSURESensorTypeCharacteristic);
                }
                spressure_scan_interval.setOnEditorActionListener(new OnEditorActionListener() {

                    @Override
                    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                        if (actionId == EditorInfo.IME_ACTION_DONE) {
                            int myNum = 0;

                            try {
                                myNum = Integer.parseInt(stemp_scan_interval.getText().toString());
                            } catch (NumberFormatException nfe) {
                                nfe.printStackTrace();
                            }
                            byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum));
                            BluetoothLeService.writeCharacteristicNoresponse(
                                    mReadSPRESSURESensorScanCharacteristic, convertedBytes);
                        }
                        return false;
                    }
                });
                Spinner spinner_filterconfiguration = (Spinner) rootView
                        .findViewById(R.id.spressure_filter_configuration);
                // Create an ArrayAdapter using the string array and a
                // default
                // spinner layout
                ArrayAdapter<CharSequence> adapter_filterconfiguration = ArrayAdapter.createFromResource(
                        getActivity(), R.array.filter_configuration_alert_array,
                        android.R.layout.simple_spinner_item);
                // Specify the layout to use when the list of choices
                // appears
                adapter_filterconfiguration
                        .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                // Apply the adapter to the spinner
                spinner_filterconfiguration.setAdapter(adapter_filterconfiguration);
                spressure_threshold_value = (EditText) rootView.findViewById(R.id.spressure_threshold);
                spressure_threshold_value.setOnEditorActionListener(new OnEditorActionListener() {

                    @Override
                    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                        if (actionId == EditorInfo.IME_ACTION_DONE) {
                            int myNum = 0;

                            try {
                                myNum = Integer.parseInt(spressure_threshold_value.getText().toString());
                            } catch (NumberFormatException nfe) {
                                nfe.printStackTrace();
                            }
                            byte[] convertedBytes = convertingTobyteArray(Integer.toString(myNum));
                            BluetoothLeService.writeCharacteristicNoresponse(
                                    mReadSPRESSUREThresholdCharacteristic, convertedBytes);
                        }
                        return false;
                    }
                });

            } else {
                spressure_more.setRotation(-90);
                spressure_scan_interval.setText("");
                spressure_sensortype.setText("");
                spressure_threshold_value.setText("");
                CustomSlideAnimation a = new CustomSlideAnimation(spressure_layLayout,
                        CustomSlideAnimation.COLLAPSE);
                height = a.getHeight();
                spressure_layLayout.startAnimation(a);
            }

        }
    });
    ImageButton acc_graph = (ImageButton) rootView.findViewById(R.id.acc_graph);
    setupAccChart(rootView);

    acc_graph.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mACCGraphLayoutParent.getVisibility() != View.VISIBLE) {
                mACCGraphLayoutParent.setVisibility(View.VISIBLE);

            } else {
                mACCGraphLayoutParent.setVisibility(View.GONE);
            }

        }
    });
    ImageButton stemp_graph = (ImageButton) rootView.findViewById(R.id.temp_graph);
    setupTempGraph(rootView);
    stemp_graph.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mTemperatureGraphLayoutParent.getVisibility() != View.VISIBLE) {
                mTemperatureGraphLayoutParent.setVisibility(View.VISIBLE);
            } else {
                mTemperatureGraphLayoutParent.setVisibility(View.GONE);
            }

        }
    });
    ImageButton spressure_graph = (ImageButton) rootView.findViewById(R.id.pressure_graph);
    setupPressureGraph(rootView);

    spressure_graph.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mPressureGraphLayoutParent.getVisibility() != View.VISIBLE) {
                mPressureGraphLayoutParent.setVisibility(View.VISIBLE);

            } else {

                mPressureGraphLayoutParent.setVisibility(View.GONE);
            }

        }
    });
    setHasOptionsMenu(true);
    return rootView;
}

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

public static AlertDialog getaddtextdialog(String title, final int itemnumber, Context ctx) {

    AlertDialog.Builder getaddtext = new AlertDialog.Builder(ctx);

    final LinearLayout linearlayout = new LinearLayout(ctx);
    linearlayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    linearlayout.setOrientation(LinearLayout.VERTICAL);

    final EditText nameet = new EditText(ctx);
    nameet.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    final TextView fontname = new TextView(ctx);
    fontname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    final TextView colorname = new TextView(ctx);
    colorname.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    final Spinner fontsizespinner = new Spinner(ctx);
    fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    final Spinner colorspinner = new Spinner(ctx);
    fontsizespinner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    List<String> fontsizelist = new ArrayList<String>();
    for (int t = 1; t < 200; t++) {
        fontsizelist.add(u.s(t));/*from   ww w.  j ava2s .co  m*/
    }
    ArrayAdapter<String> fontsizearrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview,
            fontsizelist);
    fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview);

    List<String> colorlist = new ArrayList<String>();
    {
        colorlist.add("RED");
        colorlist.add("BLACK");
        colorlist.add("BLUE");
        colorlist.add("GREEN");
        colorlist.add("WHITE");
        colorlist.add("GRAY");
    }
    ArrayAdapter<String> colorlistarrayadapter = new ArrayAdapter<String>(ctx, R.layout.spinnertextview,
            colorlist);
    fontsizearrayadapter.setDropDownViewResource(R.layout.spinnertextview);
    colorspinner.setAdapter(colorlistarrayadapter);
    fontsizespinner.setAdapter(fontsizearrayadapter);
    fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, "25"));

    fontname.setText("Select Font Size");
    fontname.setTextSize(20f);
    colorname.setText("Select Color");
    colorname.setTextSize(20f);

    linearlayout.addView(nameet);
    linearlayout.addView(fontname);
    linearlayout.addView(fontsizespinner);
    linearlayout.addView(colorname);
    linearlayout.addView(colorspinner);

    if (!(itemnumber == view.i)) {
        nameet.setText(view.ITEMstring[itemnumber]);
        fontsizespinner.setSelection(getIndexofSpinner(fontsizespinner, u.s(view.ITEMfontsize[itemnumber])));
        colorspinner.setSelection(getIndexofSpinner(colorspinner, u.s(view.ITEMfontcolor[itemnumber])));
    }

    getaddtext.setView(linearlayout);
    getaddtext.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });
    getaddtext.setTitle(title);
    getaddtext.setPositiveButton("OK", new DialogInterface.OnClickListener() {

        @Override

        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            String string = nameet.getText().toString();

            float fontsize = fontsizespinner.getSelectedItemPosition() + 1;
            //ITEMelcnumber[itemselectednumber]=u.i(string);
            int colpos = colorspinner.getSelectedItemPosition();
            int[] col = new int[] { Color.RED, Color.BLACK, Color.BLUE, Color.GREEN, Color.WHITE, Color.GRAY };
            int color = col[colpos];

            Log.d("addtext", u.s((int) fontsize) + colpos + color);

            view.ITEMstring[itemnumber] = string;
            view.ITEMfontsize[itemnumber] = (int) fontsize;
            view.ITEMfontcolor[itemnumber] = color;

            view.itemname = string;
            view.fontsize = (int) fontsize;
            view.color = color;
            view.invalidate();
            dialog.dismiss();
            FloorPlanActivity.writeonedbitem(itemnumber);
        }

    });

    return getaddtext.create();
}