mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-16 20:00:39 +01:00
display only as many days as there are in the current month
This commit is contained in:
parent
6e4d4a4f7e
commit
883f30e361
@ -7,6 +7,8 @@ import android.widget.TableLayout;
|
|||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -17,11 +19,18 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
TableLayout tableHolder = (TableLayout) findViewById(R.id.table_holder);
|
TableLayout tableHolder = (TableLayout) findViewById(R.id.table_holder);
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
|
|
||||||
|
DateTime dateTime = new DateTime();
|
||||||
|
final int currMonthDays = dateTime.dayOfMonth().getMaximumValue();
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
final TableRow row = (TableRow) inflater.inflate(R.layout.table_row, tableHolder, false);
|
final TableRow row = (TableRow) inflater.inflate(R.layout.table_row, tableHolder, false);
|
||||||
for (int j = 1; j < 8; j++) {
|
for (int j = 1; j < 8; j++) {
|
||||||
|
final int currDate = i * 7 + j;
|
||||||
|
if (currDate > currMonthDays)
|
||||||
|
break;
|
||||||
|
|
||||||
final TextView day = (TextView) inflater.inflate(R.layout.table_day, row, false);
|
final TextView day = (TextView) inflater.inflate(R.layout.table_day, row, false);
|
||||||
day.setText("" + (i * 7 + j));
|
day.setText(String.valueOf(currDate));
|
||||||
row.addView(day);
|
row.addView(day);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user