乘车记录的点击事件,将值传递到记录详情界面

This commit is contained in:
huangrui 2024-05-25 16:02:02 +08:00
parent 624f89a682
commit f1d353d947
4 changed files with 43 additions and 13 deletions

View File

@ -69,11 +69,6 @@ public class SubwayHistory extends AppCompatActivity {
//请求成功
String result = response.body().string();
Log.i("test",result);
// try {
// Thread.sleep(5000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
//所有对于UI控件的操作行为放在主线程中 解决方法切换到主线程
@ -84,7 +79,6 @@ public class SubwayHistory extends AppCompatActivity {
Gson gson = new Gson();
history_item historyItem = gson.fromJson(result,history_item.class);
history_items.addAll(historyItem.takeHistory); // 将解析的数据添加到列表中
// stationItemList.addAll(station_item);
myAdapter.notifyDataSetChanged();
} catch (Exception e) {
@ -147,6 +141,10 @@ public class SubwayHistory extends AppCompatActivity {
public void onClick(View v) {
//TODO 跳转到行程详情
Intent intent = new Intent(SubwayHistory.this, linedetail.class);
intent.putExtra("start",historyItem.start);
intent.putExtra("end",historyItem.end);
intent.putExtra("price",historyItem.price);
intent.putExtra("time",historyItem.time);
startActivity(intent);
}
});

View File

@ -6,6 +6,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
public class linedetail extends AppCompatActivity {
@ -13,6 +14,18 @@ public class linedetail extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_linedetail);
String start = getIntent().getStringExtra("start");
String end = getIntent().getStringExtra("end");
String time = getIntent().getStringExtra("time");
String price = getIntent().getStringExtra("price");
TextView startText = findViewById(R.id.textView30);
startText.setText(start);
TextView endText = findViewById(R.id.textView31);
endText.setText(end);
TextView timeText = findViewById(R.id.time);
timeText.setText(time);
TextView priceText = findViewById(R.id.price);
priceText.setText(price);
//todo 返回首页
ImageView back = findViewById(R.id.imageView13);
back.setOnClickListener(new View.OnClickListener() {

View File

@ -42,7 +42,7 @@ MyFragment myFragment = new MyFragment();
findViewById(R.id.imageView38).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getSupportFragmentManager().beginTransaction().hide(shouyeFragment).hide(myFragment).show(takeSubwayFragment).commit();
getSupportFragmentManager().beginTransaction().hide(takeSubwayFragment).hide(myFragment).show(shouyeFragment).commit();
}
});
//todo 扫码进站

View File

@ -137,7 +137,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="44dp"
android:text="票价¥6.00"
android:text="票价:"
android:textColor="#8E8585"
app:layout_constraintBottom_toBottomOf="@+id/textView40"
app:layout_constraintStart_toEndOf="@+id/textView40"
@ -148,12 +148,12 @@
android:id="@+id/textView42"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginStart="8dp"
android:text="优惠:-¥1.20"
android:textColor="#8E8585"
app:layout_constraintBottom_toBottomOf="@+id/textView41"
app:layout_constraintStart_toEndOf="@+id/textView41"
app:layout_constraintTop_toTopOf="@+id/textView41" />
app:layout_constraintBottom_toBottomOf="@+id/price"
app:layout_constraintStart_toEndOf="@+id/price"
app:layout_constraintTop_toTopOf="@+id/price" />
<TextView
android:id="@+id/textView43"
@ -170,7 +170,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="交易时间 2018-12-17 09:13"
android:text="交易时间"
android:textColor="#8E8585"
app:layout_constraintStart_toStartOf="@+id/textView43"
app:layout_constraintTop_toBottomOf="@+id/textView43" />
@ -184,6 +184,25 @@
app:layout_constraintBottom_toBottomOf="@+id/textView30"
app:layout_constraintStart_toEndOf="@+id/textView30"
app:layout_constraintTop_toTopOf="@+id/textView30" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="@+id/textView44"
app:layout_constraintStart_toEndOf="@+id/textView44"
app:layout_constraintTop_toTopOf="@+id/textView44" />
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="@+id/textView41"
app:layout_constraintStart_toEndOf="@+id/textView41"
app:layout_constraintTop_toTopOf="@+id/textView41" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>