Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Eingabefeld in Android Tabelle

25.09.2018 (👁173)
                       

Eingabefeld in Android

Wie stellt man ein Eingabefeld in eine Tabelle.

Hierzu kann man ganz einfach ein EditText als View-Element in eine Tabellen-Row anfügen.

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

 

Die Texteingabe wird dann aktiv, sobal jemand in das Eingabefeld tippt. Dadurch erscheint die Standard-Eingabetastatur.

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

 

 

 

Kompletter 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() >--------
}