Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Input field in Android

 

How to put an input field in a table.

 

For this you can easily add an EditText as a view element in a table row.

EditText tbxDayInput = new EditText(this);
row.addView(tbxDayInput);

 

The text input is then active, as soon as someone taps into the input field. This will bring up the default input keyboard.

 

 

//--< dayInput >--
EditText tbxDayInput = new EditText(this);
row.addView(tbxDayInput);
//--</ dayInput >--

 

 

 

Complete TAbellen code

public void create_Table(int Calendar_Year, int Calendar_Month) {
    //-------< create_Table() >------
    LinearLayout stack_Horizontal = findViewById(R.id.stack_Horizontal);

    LinearLayout stack_Month_Header_Detail=new LinearLayout(this);
    stack_Month_Header_Detail.setOrientation(LinearLayout.VERTICAL );


    //scroller_Vertical.setMinimumWidth(500);
    TableLayout tblHeader = new TableLayout(this);
    tblHeader.setMinimumWidth(300);

    //< Header >
    TableRow rowHeader = new TableRow(this);
    rowHeader.setBackgroundColor(Color.BLACK);

    TextView spacer = new TextView(this);
    rowHeader.addView(spacer);

    TextView lblHeaderMonth = new TextView(this);
    lblHeaderMonth.setText(Calendar_Year + "-" + Calendar_Month);    //*cast integer to string
    lblHeaderMonth.setTextColor(Color.WHITE);
    rowHeader.addView(lblHeaderMonth);
    tblHeader.addView(rowHeader);
    stack_Month_Header_Detail.addView(tblHeader);


    TableLayout tbl = new TableLayout(this);
    tbl.setMinimumWidth(300);
    //</ Header >


    //----< @Loop: Days >----
    for (int iDay = 1; iDay <= 31; iDay++) {
        //----< Day-Row >----
        //-< Date >-
        Date dtRow = clsHelper.getDate(Calendar_Year, Calendar_Month, iDay);

        //< weekday >
        //*as string
        SimpleDateFormat fmtWeekday = new SimpleDateFormat("EE");
        String weekday = fmtWeekday.format(dtRow);
        //</ weekday >

        //*as weekday_number
        Calendar calendarDay = Calendar.getInstance();
        calendarDay.setTime(dtRow);
        int NrWeekday = calendarDay.get(Calendar.DAY_OF_WEEK);//  fmtWeekdayNr.format(dtRow);
        //-</ Date >-

        //--< Row >--
        TableRow row = new TableRow(this);
        if (NrWeekday == Calendar.SATURDAY || NrWeekday == Calendar.SUNDAY) {
            row.setBackgroundColor(Color.rgb(200, 200, 200));
        }

        if (dtRow.equals(dtToday)) {
            row.setBackgroundColor(Color.rgb(200, 0, 0));
        }

        //< dayNr >
        TextView lblDayNr = new TextView(this);
        lblDayNr.setText(String.valueOf(iDay));    //*cast integer to string
        row.addView(lblDayNr);
        //</ dayNr >

        //--< weekday >--
        TextView lblWeekday = new TextView(this);
        lblWeekday.setText(weekday);
        row.addView(lblWeekday);
        //--</ weekday >--

        //--< dayInput >--
        EditText tbxDayInput = new EditText(this);
        row.addView(tbxDayInput);

        //--</ dayInput >--

        //--</ Row >--

        //< add to table >
        tbl.addView(row);
        //</ add to table >
        //----</ Day-Row >----
    }

    //< add MonthDetails to placeholder >
    ScrollView scroll_Month_UpDown = new ScrollView(this);
    scroll_Month_UpDown.addView(tbl);
    stack_Month_Header_Detail.addView(scroll_Month_UpDown);
    //</ add MonthDetails to placeholder >

    stack_Horizontal.addView(stack_Month_Header_Detail);
    //-------</ create_Table() >--------
}

 

 

Mobile
»
Android Java: Read text from a resource file
»
Android Java: Create unique GUID at runtime
»
Android Java: Comparison with empty string
»
Android java: Code area // region - // endregion
»
Android: Create a color picker
»
Android: View items by name or tag or id
»
Android Java: Create a view event at runtime and assign it to a view element
»
Android Java: Create view button at runtime
»
Android Java: create a view element as a float
»
Input field in Android

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de