Example usage for android.widget TableLayout TableLayout

List of usage examples for android.widget TableLayout TableLayout

Introduction

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

Prototype

public TableLayout(Context context) 

Source Link

Document

Creates a new TableLayout for the given context.

Usage

From source file:com.example.drugsformarinemammals.Dose_Information.java

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

    Bundle parameters = this.getIntent().getExtras();
    if (parameters != null) {
        TextView textViewDrug = (TextView) findViewById(R.id.textView_drug_name);
        textViewDrug.setTypeface(Typeface.SANS_SERIF);
        textViewDrug.setText(parameters.getString("drugName"));
        TextView textViewGroupName = (TextView) findViewById(R.id.textView_group_name);
        textViewGroupName.setTypeface(Typeface.SANS_SERIF);
        textViewGroupName.setText("(" + parameters.getString("groupName") + ")");
        layoutDose = (LinearLayout) findViewById(R.id.layout_dose);

        helper = new Handler_Sqlite(this);
        SQLiteDatabase db = helper.open();
        ArrayList<String> notes_index = new ArrayList<String>();
        ArrayList<String> references = new ArrayList<String>();
        ArrayList<Article_Reference> references_index = new ArrayList<Article_Reference>();
        reference_index = 'a';
        ArrayList<String> families = new ArrayList<String>();
        if (db != null)
            families = helper.read_animals_family(parameters.getString("drugName"),
                    parameters.getString("groupName"));

        for (int l = 0; l < families.size(); l++) {
            //if exists animals family

            TextView textView_family = new TextView(this);
            textView_family.setText(families.get(l));
            textView_family.setTextSize(20);
            textView_family.setTextColor(getResources().getColor(R.color.darkGray));
            textView_family.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());

            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            params.leftMargin = 30;//from w  ww. ja  v a2s  . c o  m
            params.topMargin = 20;
            layoutDose.addView(textView_family, layoutDose.getChildCount(), params);

            //dose information

            LinearLayout layout_dose_information = new LinearLayout(this);
            layout_dose_information.setOrientation(LinearLayout.VERTICAL);
            layout_dose_information
                    .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
            layout_dose_information.setBackgroundResource(R.drawable.layout_border);

            ArrayList<Dose_Data> dose = new ArrayList<Dose_Data>();
            if (db != null) {
                dose = helper.read_dose_information(parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l), "", "");
            }
            TableLayout doseTable = new TableLayout(this);
            doseTable.setStretchAllColumns(true);

            screenWidth = Integer.parseInt(getString(R.string.display));

            TableRow header = new TableRow(this);

            //Amount

            TextView textView_dose_amount = new TextView(this);
            textView_dose_amount.setText("Dose");
            textView_dose_amount.setSingleLine(true);
            textView_dose_amount.setTextColor(getResources().getColor(R.color.darkGray));
            textView_dose_amount.setTextSize(17);
            textView_dose_amount.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsAmount.gravity = Gravity.CENTER;
            header.addView(textView_dose_amount, paramsAmount);

            //Posology
            TextView textView_posology = new TextView(this);
            if (screenWidth >= 720)
                textView_posology.setText("Posology");
            else
                textView_posology.setText("Pos");
            textView_posology.setSingleLine(true);
            textView_posology.setTextColor(getResources().getColor(R.color.darkGray));
            textView_posology.setTextSize(17);
            textView_posology.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsPosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsPosology.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"),
                    parameters.getString("groupName"), families.get(l), "Posology")) || screenWidth >= 600)
                header.addView(textView_posology, paramsPosology);

            //Route

            TextView textView_route = new TextView(this);
            textView_route.setText("Route");
            textView_route.setSingleLine(true);
            textView_route.setTextColor(getResources().getColor(R.color.darkGray));
            textView_route.setTextSize(17);
            textView_route.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsRoute = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsRoute.gravity = Gravity.CENTER;
            header.addView(textView_route, paramsRoute);

            //Reference

            TextView textView_reference = new TextView(this);
            textView_reference.setText("Ref");
            textView_reference.setSingleLine(true);
            textView_reference.setTextColor(getResources().getColor(R.color.darkGray));
            textView_reference.setTextSize(17);
            textView_reference.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsReference = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsReference.gravity = Gravity.CENTER;
            header.addView(textView_reference, paramsReference);

            //Specific Note

            TextView textView_specific_note = new TextView(this);
            textView_specific_note.setText("Note");
            textView_specific_note.setSingleLine(true);
            textView_specific_note.setTextColor(getResources().getColor(R.color.darkGray));
            textView_specific_note.setTextSize(17);
            textView_specific_note.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsSpecificNote = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNote.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"),
                    parameters.getString("groupName"), families.get(l), "Note")) || screenWidth >= 600)
                header.addView(textView_specific_note, paramsSpecificNote);

            TableRow doseData = new TableRow(this);
            doseTable.addView(header);

            //General Dose

            if (dose.size() > 0) {
                show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l), "", "", notes_index, references,
                        references_index);
            }

            HashMap<String, ArrayList<String>> animal_information = new HashMap<String, ArrayList<String>>();
            if (db != null)
                animal_information = helper.read_animal_information(parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l));

            String animalName;
            Object[] animalsName = animal_information.keySet().toArray();
            for (int i = 0; i < animalsName.length; i++) {
                doseData = new TableRow(this);

                //if exists animal name
                animalName = (String) animalsName[i];
                TextView textView_animal_name = new TextView(this);
                if (!animalName.equals("")) {

                    //Animal name

                    textView_animal_name.setText(animalName);
                    textView_animal_name.setSingleLine(false);
                    textView_animal_name.setTextColor(getResources().getColor(R.color.darkGray));
                    textView_animal_name.setTextSize(15);
                    textView_animal_name.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
                }

                //if exists category
                ArrayList<String> categories = animal_information.get(animalName);
                String animalCategory;
                for (int j = 0; j < categories.size(); j++) {

                    animalCategory = categories.get(j);

                    if (!animalCategory.equals("")) {

                        //Animal category

                        TextView textView_animal_category = new TextView(this);
                        textView_animal_category.setText(animalCategory);
                        textView_animal_category.setSingleLine(false);
                        textView_animal_category.setTextColor(Color.BLACK);
                        textView_animal_category.setTextSize(15);
                        textView_animal_category.setTypeface(Typeface.SANS_SERIF);
                        if (!animalName.equals("")) {
                            if (j == 0) {
                                TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams(
                                        TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                                if (screenWidth < 600
                                        && isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Posology")
                                        && isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Note"))
                                    paramsAnimalName.span = 3;
                                else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Posology")
                                        || isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Note")))
                                    paramsAnimalName.span = 4;
                                else
                                    paramsAnimalName.span = 5;

                                doseData.addView(textView_animal_name, paramsAnimalName);
                                doseTable.addView(doseData);
                            }

                            if (db != null)
                                dose = helper.read_dose_information(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), animalName,
                                        animalCategory);

                            doseData = new TableRow(this);
                            textView_animal_category.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);
                            TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams(
                                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                            if (screenWidth < 600
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Posology")
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note"))
                                paramsCategoryName.span = 3;
                            else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), "Posology")
                                    || isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note")))
                                paramsCategoryName.span = 4;
                            else
                                paramsCategoryName.span = 5;
                            if (screenWidth < 600)
                                paramsCategoryName.leftMargin = 15;
                            else if (screenWidth >= 600 && screenWidth < 720)
                                paramsCategoryName.leftMargin = 20;
                            else
                                paramsCategoryName.leftMargin = 30;
                            doseData.addView(textView_animal_category, paramsCategoryName);
                            doseTable.addView(doseData);
                            doseData = new TableRow(this);
                            show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory, notes_index, references, references_index);

                            doseData = new TableRow(this);
                        } else {
                            if (db != null)
                                dose = helper.read_dose_information(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), animalName,
                                        animalCategory);

                            textView_animal_category.setTypeface(Typeface.SANS_SERIF,
                                    Typeface.DEFAULT_BOLD.getStyle());
                            textView_animal_category.setTextColor(getResources().getColor(R.color.darkGray));
                            TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams(
                                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                            if (screenWidth < 600
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Posology")
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note"))
                                paramsCategoryName.span = 3;
                            else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), "Posology")
                                    || isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note")))
                                paramsCategoryName.span = 4;
                            else
                                paramsCategoryName.span = 5;
                            doseData.addView(textView_animal_category, paramsCategoryName);
                            doseTable.addView(doseData);
                            doseData = new TableRow(this);
                            show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory, notes_index, references, references_index);

                            doseData = new TableRow(this);
                        }

                    }

                    if (!animalName.equals("") && animalCategory.equals("")) {
                        if (db != null)
                            dose = helper.read_dose_information(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory);

                        TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams(
                                TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                        if (screenWidth < 600
                                && isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Posology")
                                && isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Note"))
                            paramsAnimalName.span = 3;
                        else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                parameters.getString("groupName"), families.get(l), "Posology")
                                || isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Note")))
                            paramsAnimalName.span = 4;
                        else
                            paramsAnimalName.span = 5;
                        doseData.addView(textView_animal_name, paramsAnimalName);
                        doseTable.addView(doseData);
                        doseData = new TableRow(this);
                        show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                parameters.getString("groupName"), families.get(l), animalName, animalCategory,
                                notes_index, references, references_index);

                        doseData = new TableRow(this);
                    }
                }

            }

            LinearLayout.LayoutParams paramsDoseTable = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            if (screenWidth >= 600) {
                paramsDoseTable.topMargin = 5;
                paramsDoseTable.leftMargin = 50;
                paramsDoseTable.rightMargin = 50;
            } else {
                paramsDoseTable.topMargin = 5;
                paramsDoseTable.leftMargin = 60;
                paramsDoseTable.rightMargin = 30;
            }
            layout_dose_information.addView(doseTable, paramsDoseTable);

            layoutDose.addView(layout_dose_information, layoutDose.getChildCount());
        }
        helper.close();

        //Notes
        additionalInformationInterface("GENERAL NOTES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);
        additionalInformationInterface("SPECIFIC NOTES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);
        //References
        additionalInformationInterface("REFERENCES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);

    }

}

From source file:org.spinsuite.view.V_StandardSearch.java

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    super.setContentView(R.layout.v_search);
    //   Get Field
    Bundle bundle = getIntent().getExtras();
    String subtitle = null;/*from w ww  .ja va 2  s  .c om*/
    if (bundle != null) {
        m_field = (InfoField) bundle.getParcelable("Field");
        m_SPS_Table_ID = bundle.getInt("SPS_Table_ID");
        m_SPS_Tab_ID = bundle.getInt("SPS_Tab_ID");
        String m_StringInsertRecord = bundle.getString("IsInsertRecord");
        m_criteria = bundle.getParcelable("Criteria");
        subtitle = bundle.getString("Name");
        //   Valid Is Insert Record
        if (m_StringInsertRecord != null)
            m_IsInsertRecord = m_StringInsertRecord.equals("Y");
    }
    //   Set Activity
    v_activity = this;
    //   Get Record Count
    tv_RecordCount = (TextView) findViewById(R.id.tv_RecordCount);
    //   
    tv_RecordCount.setText(Msg.getMsg(v_activity, "record.found") + ": 0");
    //   
    sv_Search = (ScrollView) findViewById(R.id.sv_Search);
    //   Table Layout
    v_tableLayout = new TableLayout(this);
    sv_Search.addView(v_tableLayout);
    //   
    lv_Search = (ListView) findViewById(R.id.lv_Search);
    //   
    if (m_SPS_Table_ID != 0) {
        lookup = new Lookup(getApplicationContext(), m_SPS_Table_ID);
    } else if (m_field != null) {
        lookup = new Lookup(getApplicationContext(), m_field);
        subtitle = m_field.Name;
    }
    //   
    //   Set Subtitle
    getActionBar().setSubtitle(subtitle);
    //   Set Configuration
    loadConfig();

    //   Load
    new LoadViewTask().execute();
    //   Listener
    lv_Search.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View arg1, int position, long arg3) {
            //   Load from Action
            selectedRecord(m_SearchAdapter.getItem(position));
        }
    });
}

From source file:eu.power_switch.gui.adapter.SceneRecyclerViewAdapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Scene scene = scenes.get(holder.getAdapterPosition());

    String inflaterString = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater inflater = (LayoutInflater) fragmentActivity.getSystemService(inflaterString);

    holder.sceneName.setText(scene.getName());
    holder.sceneName.setOnClickListener(new View.OnClickListener() {
        @Override/* w  w  w  .java  2 s .c  o  m*/
        public void onClick(View v) {
            if (holder.linearLayoutSceneItems.getVisibility() == View.VISIBLE) {
                holder.linearLayoutSceneItems.setVisibility(View.GONE);
            } else {
                holder.linearLayoutSceneItems.setVisibility(View.VISIBLE);
            }
        }
    });
    holder.sceneName.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (onItemLongClickListener != null) {
                onItemLongClickListener.onItemLongClick(v, holder.getAdapterPosition());
            }
            return true;
        }
    });

    holder.buttonActivateScene.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) {
                VibrationHandler.vibrate(fragmentActivity, SmartphonePreferencesHandler.getVibrationDuration());
            }

            new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... params) {
                    ActionHandler.execute(fragmentActivity, scene);
                    return null;
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    });

    // clear previous items
    holder.linearLayoutSceneItems.removeAllViews();
    // hide setup by default
    holder.linearLayoutSceneItems.setVisibility(View.GONE);
    // add current setup
    for (final SceneItem sceneItem : scene.getSceneItems()) {
        // create a new receiverRow for our current receiver and add it
        // to our table of all devices of our current room
        // the row will contain the device name and all buttons
        LinearLayout receiverRow = new LinearLayout(fragmentActivity);
        receiverRow.setOrientation(LinearLayout.HORIZONTAL);
        holder.linearLayoutSceneItems.addView(receiverRow);

        // setup TextView to display receiver name
        AppCompatTextView receiverName = new AppCompatTextView(fragmentActivity);
        receiverName.setText(sceneItem.getReceiver().getName());
        receiverName.setTextSize(18);
        receiverName
                .setTextColor(ThemeHelper.getThemeAttrColor(fragmentActivity, android.R.attr.textColorPrimary));
        receiverName.setGravity(Gravity.CENTER_VERTICAL);
        receiverRow.addView(receiverName,
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f));

        TableLayout buttonLayout = new TableLayout(fragmentActivity);
        receiverRow.addView(buttonLayout,
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        int buttonsPerRow;
        if (sceneItem.getReceiver().getButtons().size() % 3 == 0) {
            buttonsPerRow = 3;
        } else {
            buttonsPerRow = 2;
        }

        int i = 0;
        TableRow buttonRow = null;
        for (final Button button : sceneItem.getReceiver().getButtons()) {
            final android.widget.Button buttonView = (android.widget.Button) inflater
                    .inflate(R.layout.simple_button, buttonRow, false);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                buttonView.setElevation(0);
                buttonView.setStateListAnimator(null);
            }
            buttonView.setText(button.getName());
            buttonView.setEnabled(false);

            final int accentColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.colorAccent);
            final int inactiveColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.textColorInactive);
            if (sceneItem.getActiveButton().equals(button)) {
                buttonView.setTextColor(accentColor);
            } else {
                buttonView.setTextColor(inactiveColor);
            }

            if (i == 0 || i % buttonsPerRow == 0) {
                buttonRow = new TableRow(fragmentActivity);
                buttonRow.setLayoutParams(
                        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
                buttonRow.addView(buttonView);
                buttonLayout.addView(buttonRow);
            } else {
                buttonRow.addView(buttonView);
            }

            i++;
        }
    }

    if (holder.getAdapterPosition() == getItemCount() - 1) {
        holder.footer.setVisibility(View.VISIBLE);
    } else {
        holder.footer.setVisibility(View.GONE);
    }
}

From source file:org.spinsuite.view.T_DynamicTab.java

/**
 * Init Fragment//  w  ww.  j av a  2s .c om
 * @author <a href="mailto:yamelsenih@gmail.com">Yamel Senih</a> 02/04/2014, 13:50:51
 * @return void
 */
private void initLoad() {
    //   
    m_IsLoadOk = true;
    //   Retain Instance
    if (tabParam.getTabLevel() == 0)
        setRetainInstance(true);

    m_Record_ID = Env.getTabRecord_ID(getActivity(), tabParam.getActivityNo(), tabParam.getTabNo());
    //   Parent
    m_Parent_Record_ID = Env.getTabRecord_ID(getActivity(), tabParam.getActivityNo(),
            tabParam.getParentTabNo());

    //   Set Parameter
    v_param = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, WEIGHT);
    //   Table Layout
    v_tableLayout = new TableLayout(getActivity());
    //   Add View
    v_scroll.addView(v_tableLayout);
    //   View
    viewList = new ArrayList<ViewIndex>();
    //   
    loadView();
}

From source file:li.klass.fhem.adapter.devices.genericui.AvailableTargetStatesDialogUtil.java

public static <D extends FhemDevice<D>> TypeHandler<D> handlerForSelectedOption(D device, Context context,
        final String option, final TargetStateSelectedCallback callback) {

    SetList setList = device.getSetList();
    final SetListValue setListValue = setList.get(option);

    final DeviceStateRequiringAdditionalInformation specialDeviceState = DeviceStateRequiringAdditionalInformation
            .deviceStateForFHEM(option);

    if (setListValue instanceof SetListSliderValue) {
        final SetListSliderValue sliderValue = (SetListSliderValue) setListValue;
        return new TypeHandler<D>() {
            private int dimProgress = 0;

            @Override/*  ww  w  .j a  va 2s .  c  om*/
            public View getContentViewFor(Context context, D device) {
                TableLayout tableLayout = new TableLayout(context);
                int initialProgress = 0;
                if (device instanceof DimmableDevice) {
                    initialProgress = ((DimmableDevice) device).getDimPosition();
                }

                tableLayout.addView(new DeviceDimActionRowFullWidth<D>(initialProgress, sliderValue.getStart(),
                        sliderValue.getStep(), sliderValue.getStop(), null,
                        R.layout.device_detail_seekbarrow_full_width) {

                    @Override
                    public void onStopDim(Context context, D device, int progress) {
                        dimProgress = progress;
                    }

                    @Override
                    public String toDimUpdateText(D device, int progress) {
                        return null;
                    }
                }.createRow(LayoutInflater.from(context), device));
                return tableLayout;
            }

            @Override
            public boolean onPositiveButtonClick(View view, Context context, D device) {
                callback.onTargetStateSelected(option, "" + dimProgress, device, context);
                return true;
            }
        };
    } else if (setListValue instanceof SetListGroupValue) {
        final SetListGroupValue groupValue = (SetListGroupValue) setListValue;
        final List<String> groupStates = groupValue.getGroupStates();
        return new TypeHandler<D>() {

            @Override
            public View getContentViewFor(final Context context, final D device) {
                ListView listView = new ListView(context);
                listView.setAdapter(
                        new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, groupStates));
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                        String selection = groupStates.get(position);
                        callback.onTargetStateSelected(option, selection, device, context);
                        dialog.dismiss();
                    }
                });

                return listView;
            }

            @Override
            boolean requiresPositiveButton() {
                return false;
            }
        };
    } else if (specialDeviceState != null) {
        return new TypeHandler<D>() {

            private EditText editText;

            @Override
            public View getContentViewFor(Context context, D device) {
                editText = new EditText(context);
                return editText;
            }

            @Override
            public boolean onPositiveButtonClick(View view, Context context, D device) {
                Editable value = editText.getText();
                String text = value == null ? "" : value.toString();

                if (isValidAdditionalInformationValue(text, specialDeviceState)) {
                    callback.onTargetStateSelected(option, text, device, context);
                    return true;
                } else {
                    DialogUtil.showAlertDialog(context, R.string.error, R.string.invalidInput);
                    return false;
                }
            }
        };
    } else {
        callback.onTargetStateSelected(option, null, device, context);
        return null;
    }
}

From source file:com.ehret.mixit.fragment.PeopleDetailFragment.java

private void addPeopleLink(Member membre) {
    //On vide les lments
    linkLayout.removeAllViews();//from  ww  w  . j  a v  a  2 s.  c  om

    //On affiche les liens que si on a recuperer des choses
    if (membre != null && membre.getSharedLinks() != null && !membre.getSharedLinks().isEmpty()) {

        //On ajoute un table layout
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
        tableLayout.setLayoutParams(tableParams);

        if (mInflater != null && membre.getSharedLinks().size() > 0) {
            for (final Link link : membre.getSharedLinks()) {
                RelativeLayout row = (RelativeLayout) mInflater.inflate(R.layout.item_link, tableLayout, false);
                row.setBackgroundResource(R.drawable.row_transparent_background);
                //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
                TextView link_text = (TextView) row.findViewById(R.id.link_text);
                link_text.setText(Html.fromHtml(String.format("%s : <a href=\"%s\">%s</a>", link.getRel(),
                        link.getHref(), link.getHref())));
                link_text.setBackgroundColor(Color.TRANSPARENT);
                link_text.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse(link.getHref()));
                        getActivity().startActivity(in);
                    }

                });
                tableLayout.addView(row);
            }
        } else {
            RelativeLayout row = (RelativeLayout) mInflater.inflate(R.layout.item_link, tableLayout, false);
            row.setBackgroundResource(R.drawable.row_transparent_background);
            //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
            TextView link_text = (TextView) row.findViewById(R.id.link_text);
            link_text.setText("Aucun lien");
            link_text.setBackgroundColor(Color.TRANSPARENT);
            tableLayout.addView(row);
        }
        linkLayout.addView(tableLayout);
    } else {
        titleLinks.getLayoutParams().height = 0;
    }
}

From source file:org.spinsuite.view.V_Process.java

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    super.setContentView(R.layout.v_process);
    //   Get Field
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        m_field = (InfoField) bundle.getParcelable("Field");
        m_activityParam = (ActivityParameter) bundle.getParcelable("Param");
    }// w ww.jav a 2s.  co  m
    //   
    if (m_field == null)
        m_field = new InfoField();
    //   
    if (m_activityParam == null)
        m_activityParam = new ActivityParameter();
    //   Get Elements
    ll_HeaderReport = (LinearLayout) findViewById(R.id.ll_HeaderReport);
    ll_ProcessPara = (LinearLayout) findViewById(R.id.ll_ProcessPara);
    tv_Description = (TextView) findViewById(R.id.tv_Description);
    tv_Help = (TextView) findViewById(R.id.tv_Help);
    sv_Param = (ScrollView) findViewById(R.id.sv_Param);
    lv_LogReport = (ListView) findViewById(R.id.lv_LogReport);
    //   Set Parameter
    v_rowParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, WEIGHT);
    //   Table Layout
    v_tableLayout = new TableLayout(this);
    //   Add View
    sv_Param.addView(v_tableLayout);
    //   
    viewList = new ArrayList<ViewIndex>();
    //   Title
    getActionBar().setSubtitle(m_activityParam.getName());
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    //   
    loadProcessInfo();
    //   Load Drawer
    loadDrawerOption();
    //   Load Print Formats
    loadPrintFormat();
}

From source file:com.vonglasow.michael.satstat.ui.RadioSectionFragment.java

private final void addWifiResult(ScanResult result) {
    // needed to pass a persistent reference to the OnClickListener
    final ScanResult r = result;
    android.view.View.OnClickListener clis = new android.view.View.OnClickListener() {

        @Override/*from w  ww  .ja  v a  2 s . co m*/
        public void onClick(View v) {
            onWifiEntryClick(r.BSSID);
        }
    };

    LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
    wifiLayout.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
    wifiLayout.setWeightSum(22);
    wifiLayout.setMeasureWithLargestChildEnabled(false);

    ImageView wifiType = new ImageView(wifiAps.getContext());
    wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
    if (WifiCapabilities.isAdhoc(result)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
    } else if ((WifiCapabilities.isEnterprise(result))
            || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_open);
    } else {
        wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
    }

    wifiType.setScaleType(ScaleType.CENTER);
    wifiLayout.addView(wifiType);

    TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
    wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    TableRow innerRow1 = new TableRow(wifiAps.getContext());
    TextView newMac = new TextView(wifiAps.getContext());
    newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
    newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newMac.setText(result.BSSID);
    innerRow1.addView(newMac);
    TextView newCh = new TextView(wifiAps.getContext());
    newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newCh.setText(getChannelFromFrequency(result.frequency));
    innerRow1.addView(newCh);
    TextView newLevel = new TextView(wifiAps.getContext());
    newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newLevel.setText(String.valueOf(result.level));
    innerRow1.addView(newLevel);
    innerRow1.setOnClickListener(clis);
    wifiDetails.addView(innerRow1,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    TableRow innerRow2 = new TableRow(wifiAps.getContext());
    TextView newSSID = new TextView(wifiAps.getContext());
    newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
    newSSID.setText(result.SSID);
    innerRow2.addView(newSSID);
    innerRow2.setOnClickListener(clis);
    wifiDetails.addView(innerRow2,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    wifiLayout.addView(wifiDetails);
    wifiLayout.setOnClickListener(clis);
    wifiAps.addView(wifiLayout);
}

From source file:com.ehret.mixit.fragment.PeopleDetailFragment.java

private void addPeopleSession(Member membre) {
    //On recupere aussi la liste des sessions de l'utilisateur
    List<Talk> conferences = ConferenceFacade.getInstance().getSessionMembre(membre, getActivity());

    //On vide les lments
    sessionLayout.removeAllViews();//  w  w  w .  j  a v  a  2 s. c o  m

    //On affiche les liens que si on a recuperer des choses
    if (conferences != null && !conferences.isEmpty()) {
        //On ajoute un table layout
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
        tableLayout.setLayoutParams(tableParams);

        if (mInflater != null) {

            for (final Talk conf : conferences) {
                LinearLayout row = (LinearLayout) mInflater.inflate(R.layout.item_talk, tableLayout, false);
                row.setBackgroundResource(R.drawable.row_transparent_background);
                //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
                TextView horaire = (TextView) row.findViewById(R.id.talk_horaire);
                TextView talkImageText = (TextView) row.findViewById(R.id.talkImageText);
                TextView talkSalle = (TextView) row.findViewById(R.id.talk_salle);
                ImageView imageFavorite = (ImageView) row.findViewById(R.id.talk_image_favorite);
                ImageView langImage = (ImageView) row.findViewById(R.id.talk_image_language);

                ((TextView) row.findViewById(R.id.talk_name)).setText(conf.getTitle());
                ((TextView) row.findViewById(R.id.talk_shortdesciptif)).setText(conf.getSummary().trim());

                SimpleDateFormat sdf = new SimpleDateFormat("EEE");
                if (conf.getStart() != null && conf.getEnd() != null) {
                    horaire.setText(String.format(getResources().getString(R.string.periode),
                            sdf.format(conf.getStart()),
                            DateFormat.getTimeInstance(DateFormat.SHORT).format(conf.getStart()),
                            DateFormat.getTimeInstance(DateFormat.SHORT).format(conf.getEnd())));
                } else {
                    horaire.setText(getResources().getString(R.string.pasdate));

                }
                if (conf.getLang() != null && "ENGLISH".equals(conf.getLang())) {
                    langImage.setImageDrawable(getResources().getDrawable(R.drawable.en));
                } else {
                    langImage.setImageDrawable(getResources().getDrawable(R.drawable.fr));
                }
                Salle salle = Salle.INCONNU;
                if (conf instanceof Talk && Salle.INCONNU != Salle.getSalle(conf.getRoom())) {
                    salle = Salle.getSalle(conf.getRoom());
                }
                talkSalle.setText(String.format(getResources().getString(R.string.Salle), salle.getNom()));
                talkSalle.setBackgroundColor(getResources().getColor(salle.getColor()));

                if (conf instanceof Talk) {
                    if ("Workshop".equals(((Talk) conf).getFormat())) {
                        talkImageText.setText("Atelier");
                    } else {
                        talkImageText.setText("Talk");
                    }
                } else {
                    talkImageText.setText("L.Talk");
                }

                row.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        TypeFile typeFile;
                        int page = 6;
                        if (conf instanceof Talk) {
                            if ("Workshop".equals(((Talk) conf).getFormat())) {
                                typeFile = TypeFile.workshops;
                                page = 4;
                            } else {
                                typeFile = TypeFile.talks;
                                page = 3;
                            }
                        } else {
                            typeFile = TypeFile.lightningtalks;
                        }
                        ((HomeActivity) getActivity()).changeCurrentFragment(SessionDetailFragment.newInstance(
                                typeFile.toString(), conf.getIdSession(), page), typeFile.toString());
                    }
                });

                //On regarde si la conf fait partie des favoris
                SharedPreferences settings = getActivity().getSharedPreferences(UIUtils.PREFS_FAVORITES_NAME,
                        0);
                boolean trouve = false;
                for (String key : settings.getAll().keySet()) {
                    if (key.equals(String.valueOf(conf.getIdSession()))) {
                        trouve = true;
                        imageFavorite.setImageDrawable(
                                getActivity().getResources().getDrawable(R.drawable.ic_action_important));
                        break;
                    }
                }
                if (!trouve) {
                    imageFavorite.setImageDrawable(
                            getActivity().getResources().getDrawable(R.drawable.ic_action_not_important));
                }
                tableLayout.addView(row);
            }
        }
        sessionLayout.addView(tableLayout);
    } else {
        titleSessions.getLayoutParams().height = 0;
    }
}

From source file:com.ehret.mixit.fragment.SessionDetailFragment.java

private void addSpeakerInfo(Talk conference) {
    //On vide les lments
    sessionPersonList.removeAllViews();/*from  w  ww . j  a va  2  s  .  c o  m*/

    List<Member> speakers = new ArrayList<>();
    for (Speaker member : conference.getSpeakers()) {
        Member membre = MembreFacade.getInstance().getMembre(getActivity(), TypeFile.speaker.name(),
                member.getIdMember());

        if (membre != null) {
            speakers.add(membre);
        }
    }

    //On affiche les liens que si on a recuperer des choses
    if (!speakers.isEmpty()) {
        //On utilisait auparavant une liste pour afficher ces lments dans la page mais cette liste
        //empche d'avoir un ScrollView englobant pour toute la page. Nous utilisons donc un tableau

        //On ajoute un table layout
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
        tableLayout.setLayoutParams(tableParams);

        if (mInflater != null) {
            for (final Member membre : speakers) {
                LinearLayout row = (LinearLayout) mInflater.inflate(R.layout.item_person, tableLayout, false);
                row.setBackgroundResource(R.drawable.row_transparent_background);

                //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
                TextView userName = (TextView) row.findViewById(R.id.person_user_name);
                TextView descriptif = (TextView) row.findViewById(R.id.person_shortdesciptif);
                TextView level = (TextView) row.findViewById(R.id.person_level);
                ImageView profileImage = (ImageView) row.findViewById(R.id.person_user_image);

                userName.setText(membre.getCompleteName());

                if (membre.getShortDescription() != null) {
                    descriptif.setText(membre.getShortDescription().trim());
                }

                //Recuperation de l'mage liee au profil
                Bitmap image = FileUtils.getImageProfile(getActivity(), membre);
                if (image == null) {
                    profileImage.setImageDrawable(getResources().getDrawable(R.drawable.person_image_empty));
                } else {
                    //On regarde dans les images embarquees
                    profileImage.setImageBitmap(image);
                }

                row.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ((HomeActivity) getActivity()).changeCurrentFragment(PeopleDetailFragment
                                .newInstance(TypeFile.speaker.toString(), membre.getLogin(), 7),
                                TypeFile.speaker.toString());
                    }
                });

                tableLayout.addView(row);
            }
        }
        sessionPersonList.addView(tableLayout);
    }
}