add row selection logic with background highlighting on click

This commit is contained in:
2019-03-10 16:56:27 +01:00
parent c2a14c5b66
commit 2b7dca8e2f
2 changed files with 371 additions and 296 deletions

View File

@@ -14,6 +14,8 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
@@ -44,6 +46,28 @@ public class MainNativeActivity extends AppCompatActivity {
String urlGlobal = settings.getString("urlGlobal", getString(R.string.url_global));
if (savedInstanceState == null) {
TableLayout tr1 = findViewById(R.id.tableRow1);
tr1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: do your logic here
}
});
TableLayout tr2 = findViewById(R.id.tableRow2);
tr2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: do your logic here
}
});
TableLayout tr3 = findViewById(R.id.tableRow3);
tr3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: do your logic here
}
});
String urlPre = "";
if (SettingsActivity.isLocal(getApplicationContext())) {
//Toast.makeText(getApplicationContext(), "intern", Toast.LENGTH_LONG).show();

View File

@@ -9,8 +9,8 @@
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
@@ -42,351 +42,402 @@
</TableRow>
<TableRow
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/widget_vertical_margin">
android:layout_height="1dp"
android:background="?android:attr/listDivider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textViewTemperatureValue1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewTemperatureUnit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/temperature_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/textViewHumidityValue1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewHumidityUnit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/humidity_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
<TableLayout
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="6">
android:layout_height="wrap_content"
android:paddingTop="@dimen/widget_vertical_margin"
android:paddingBottom="@dimen/widget_vertical_margin"
android:background="?android:attr/selectableItemBackground">
<LinearLayout
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textViewTemperatureValue1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewTemperatureUnit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/temperature_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/textViewHumidityValue1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewHumidityUnit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/humidity_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
android:weightSum="6">
<TextView
android:id="@+id/textViewTemperatureMin1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTemperatureMax1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewTemperatureMin1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewTemperatureDelta1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewTemperatureMax1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTemperatureDelta1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewHumidityMin1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewHumidityMax1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityMin1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityDelta1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityMax1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewHumidityDelta1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</TableRow>
</LinearLayout>
<TableRow
</TableRow>
</TableLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/widget_vertical_margin">
android:layout_height="1dp"
android:background="?android:attr/listDivider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textViewTemperatureValue2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewTemperatureUnit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/temperature_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/textViewHumidityValue2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewHumidityUnit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/humidity_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
<TableLayout
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="6">
android:layout_height="wrap_content"
android:paddingTop="@dimen/widget_vertical_margin"
android:paddingBottom="@dimen/widget_vertical_margin"
android:background="?android:attr/selectableItemBackground">
<LinearLayout
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textViewTemperatureValue2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewTemperatureUnit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/temperature_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/textViewHumidityValue2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewHumidityUnit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/humidity_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
android:weightSum="6">
<TextView
android:id="@+id/textViewTemperatureMin2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTemperatureMax2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewTemperatureMin2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewTemperatureDelta2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewTemperatureMax2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTemperatureDelta2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewHumidityMin2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewHumidityMax2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityMin2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityDelta2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityMax2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewHumidityDelta2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</TableRow>
</LinearLayout>
<TableRow
</TableRow>
</TableLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/widget_vertical_margin">
android:layout_height="1dp"
android:background="?android:attr/listDivider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textViewTemperatureValue3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewTemperatureUnit3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/temperature_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/textViewHumidityValue3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewHumidityUnit3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/humidity_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
<TableLayout
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="6">
android:layout_height="wrap_content"
android:paddingTop="@dimen/widget_vertical_margin"
android:paddingBottom="@dimen/widget_vertical_margin"
android:background="?android:attr/selectableItemBackground">
<LinearLayout
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textViewTemperatureValue3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewTemperatureUnit3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/temperature_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/textViewHumidityValue3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/dummy_value"
android:textSize="@dimen/value_main_size"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewHumidityUnit3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_horizontal_margin"
android:text="@string/humidity_unit"
android:textSize="32sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
android:weightSum="6">
<TextView
android:id="@+id/textViewTemperatureMin3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTemperatureMax3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewTemperatureMin3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewTemperatureDelta3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewTemperatureMax3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewTemperatureDelta3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewHumidityMin3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_span="3"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewHumidityMax3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityMin3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityDelta3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
<TextView
android:id="@+id/textViewHumidityMax3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/widget_horizontal_margin"
android:text="@string/dummy_value2" />
</LinearLayout>
<TextView
android:id="@+id/textViewHumidityDelta3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_value2" />
</TableRow>
</LinearLayout>
</TableRow>
</TableLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</TableLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="80dp"