This commit is contained in:
czx 2024-06-10 21:55:17 +08:00
parent 9b54cc0fee
commit 7d83ccaa0a
9 changed files with 147 additions and 21 deletions

View File

@ -8,6 +8,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication">
<activity
android:name=".AddLocationActivity"
android:exported="false" />
<activity
android:name=".LocationActivity"
android:exported="false" />

View File

@ -0,0 +1,14 @@
package com.hnucm.c202201020117.coffee;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class AddLocationActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_location);
}
}

View File

@ -0,0 +1,64 @@
package com.hnucm.c202201020117.coffee;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
* Use the {@link HaveLocationFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class HaveLocationFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public HaveLocationFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment HaveLocationFragment.
*/
// TODO: Rename and change types and number of parameters
public static HaveLocationFragment newInstance(String param1, String param2) {
HaveLocationFragment fragment = new HaveLocationFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_have_location, container, false);
}
}

View File

@ -19,10 +19,10 @@ public class LocationActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location);
ConstraintLayout constraintLayout = findViewById(R.id.constraintLayout20);
ConstraintLayout constraintLayout1 = findViewById(R.id.AddAdress);
ImageView imageView = findViewById(R.id.imageView2);
NoneLocationFragment noneLocationFragment = new NoneLocationFragment();
HaveLocationFragment haveLocationFragment = new HaveLocationFragment();
imageView.setOnClickListener(new View.OnClickListener() {
@Override
@ -33,14 +33,28 @@ public class LocationActivity extends AppCompatActivity {
}
});
constraintLayout1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(LocationActivity.this,AddLocationActivity.class);
startActivity(intent);
}
});
getSupportFragmentManager()
.beginTransaction()
.add(R.id.constraintLayout,noneLocationFragment)
.add(R.id.constraintLayout20,noneLocationFragment)
.commit();
getSupportFragmentManager()
.beginTransaction()
.add(R.id.constraintLayout20,haveLocationFragment)
.commit();
getSupportFragmentManager()
.beginTransaction()
.show(noneLocationFragment)
.hide(haveLocationFragment)
.commit();
}
}

View File

@ -3,6 +3,7 @@ package com.hnucm.c202201020117.coffee;
import android.content.Intent;
import android.os.Bundle;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
@ -15,13 +16,15 @@ public class MineFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_mine, container, false);
view.findViewById(R.id.constraintLayout15).setOnClickListener(new View.OnClickListener() {
ConstraintLayout constraintLayout = view.findViewById(R.id.constraintLayout15);
constraintLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(),LocationActivity.class);
startActivity(intent);
}
});
// Inflate the layout for this fragment
return view;
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AddLocationActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -41,7 +41,7 @@
android:id="@+id/constraintLayout20"
android:layout_width="match_parent"
android:layout_height="700dp"
android:layout_marginBottom="111dp"
android:layout_marginBottom="110dp"
android:background="#F6F6F6"
app:layout_constraintBottom_toBottomOf="@+id/AddAdress"
app:layout_constraintEnd_toEndOf="parent"
@ -53,7 +53,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/AddAdress"
android:layout_width="match_parent"
android:layout_height="111dp"
android:layout_height="110dp"
android:background="#0022AB"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HaveLocationFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>

View File

@ -1,23 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="700dp"
android:layout_height="match_parent"
tools:context=".NoneLocationFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:src="@drawable/none_location"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:src="@drawable/none_location"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
<TextView
android:id="@+id/textView29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:text="暂无地址"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>