点击商品进入商品详细页

master
fangshicai 3 years ago
parent 60f32b1980
commit 5e8769e4dd

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RenderSettings">
<option name="showDecorations" value="true" />
</component>
</project>

@ -5,21 +5,13 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- 允许联网 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 获取GSM2g、WCDMA联通3g等网络状态的信息 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 获取wifi网络状态的信息 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 保持CPU 运转,屏幕和键盘灯有可能是关闭的,用于文件上传和下载 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- 获取sd卡写的权限用于文件上传和下载 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 允许读取手机状态 用于创建BmobInstallation -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 本地存储 (Local Storage)-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 允许联网 -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 获取GSM2g、WCDMA联通3g等网络状态的信息 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 获取wifi网络状态的信息 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 保持CPU 运转,屏幕和键盘灯有可能是关闭的,用于文件上传和下载 -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 获取sd卡写的权限用于文件上传和下载 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 允许读取手机状态 用于创建BmobInstallation -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- 本地存储 (Local Storage) -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
@ -33,9 +25,14 @@
android:supportsRtl="true"
android:theme="@style/Theme.Android_Couser_Design"
tools:targetApi="31">
<activity
android:name=".activity.GoodsDetailsActivity"
android:launchMode="singleTask"
android:exported="false" />
<activity
android:name=".activity.HomePageActivity"
android:exported="true" >
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -45,15 +42,15 @@
<activity
android:name=".activity.LoginActivity"
android:exported="false">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity android:name="com.android.MainActivity">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity android:name="com.android.MainActivity"></activity>
</application>
</manifest>

@ -0,0 +1,46 @@
package com.android.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.android.R;
import com.android.bean.Good;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public class GoodsDetailsActivity extends AppCompatActivity {
private Good good;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goods_details);
//注册EventBus
EventBus.getDefault().register(this);
}
//拿取数据
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
public void getGoods(Good data){
if(data != null){
this.good = data;
Log.e("GoodsDetailsActivity",good.getContent());
}else {
Log.e("GoodsDetailsActivity","获取失败");
}
}
@Override
protected void onDestroy() {
EventBus.getDefault().unregister(this);
super.onDestroy();
}
}

@ -19,6 +19,7 @@ import com.google.android.material.navigation.NavigationBarView;
import com.google.android.material.navigation.NavigationView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
public class HomePageActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener{
@ -32,6 +33,7 @@ public class HomePageActivity extends AppCompatActivity implements BottomNavigat
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_page);
// EventBus.getDefault().register(this);
navigation = findViewById(R.id.bottom_navigation);
navigation.setLabelVisibilityMode(NavigationBarView.LABEL_VISIBILITY_LABELED);
@ -66,6 +68,7 @@ public class HomePageActivity extends AppCompatActivity implements BottomNavigat
case R.id.item_my:
fragmentTransaction.replace(R.id.fragment_container, new MyPageFragment());
fragmentTransaction.commit();
break;
case R.id.item_shop:
fragmentTransaction.replace(R.id.fragment_container, new ShopCarPageFragment());
@ -79,9 +82,10 @@ public class HomePageActivity extends AppCompatActivity implements BottomNavigat
return true;
}
@Override
protected void onDestroy() {
// EventBus.getDefault().unregister(this);
super.onDestroy();
}
}

@ -17,10 +17,14 @@ import com.android.model.login.LoginModel;
import com.android.model.login.LoginModelImpl;
import com.android.utils.watcher.MyWatcher;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public class LoginActivity extends AppCompatActivity implements LoginListener, View.OnClickListener {
private static final String TAG ="LoginActivity";
private ResponseData responseData;
private ResponseData<User> responseData;
private EditText etPwd;
private EditText etAccount;
private Button LoginButton;
@ -82,14 +86,12 @@ public class LoginActivity extends AppCompatActivity implements LoginListener, V
this.responseData = responseData;
login();
Log.e("responseData",String.valueOf(responseData.getData().getId()));
}
@Override
public void onGetCodeSuccess(ResponseData<String> responseData) {
Log.e(TAG,"onGetCodeSuccess"+responseData.getCode());
}
@Override
@ -106,9 +108,13 @@ public class LoginActivity extends AppCompatActivity implements LoginListener, V
private void login() {
if(responseData.getCode() == 200){
Intent intent = new Intent(LoginActivity.this,HomePageActivity.class);
EventBus.getDefault().postSticky(responseData);
startActivity(intent);
}else {
Log.e("login",responseData.getMsg());
}
}
}

@ -48,7 +48,6 @@ public class GoodsAdapter extends RecyclerView.Adapter<GoodsAdapter.ViewHolder>
strTvTitle = goodArrayList.get(position).getContent();
strTvCount = goodArrayList.get(position).getPrice().toString();
imageUrl = (String) goodArrayList.get(position).getImageUrlList().get(0);
Log.e("imageUrl", (String) goodArrayList.get(position).getImageUrlList().get(0));
holder.getTvTitle().setText(strTvTitle);
holder.getTvCount().setText(strTvCount);

@ -2,6 +2,7 @@ package com.android.activity.adapter;
import static android.content.ContentValues.TAG;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.view.View;
@ -29,6 +30,9 @@ public class StaggerAdapter extends RecyclerView.Adapter<StaggerAdapter.InnerHol
protected final ArrayList<Good> mData;
private RecyclerView mList;
Context context;
private OnItemClickListener mOnItemClickListener;
public StaggerAdapter(ArrayList<Good> mData, Context context) {
Log.d("TAG", "StaggerAdapter: ");
@ -44,7 +48,6 @@ public class StaggerAdapter extends RecyclerView.Adapter<StaggerAdapter.InnerHol
@NonNull
@Override
public InnerHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Log.d("TAG", "onCreateViewHolder: ");
//传入这个view是item的界面
View view = View.inflate(parent.getContext(), R.layout.item_stagger, null);
//创建InnerHolder
@ -53,18 +56,20 @@ public class StaggerAdapter extends RecyclerView.Adapter<StaggerAdapter.InnerHol
//绑定holder一般用来设置数据
@Override
public void onBindViewHolder(@NonNull InnerHolder holder, int position) {
public void onBindViewHolder(@NonNull InnerHolder holder, int position) {
String strTvTitle;
String strTvCount;
String imageUrl;
holder.setmPosition(position);
if (mData.get(position) != null){
strTvTitle = mData.get(position).getContent();
strTvCount = mData.get(position).getPrice().toString();
imageUrl = (String) mData.get(position).getImageUrlList().get(0);
Log.d("TAG", "Title:"+strTvTitle);
Log.d("TAG", "Count:"+strTvCount);
Log.e("imageUrl", (String) mData.get(position).getImageUrlList().get(0));
holder.getTvTitle().setText(strTvTitle);
holder.getTvCount().setText(strTvCount);
@ -82,8 +87,21 @@ public class StaggerAdapter extends RecyclerView.Adapter<StaggerAdapter.InnerHol
return 0;
}
//用于监听
public void setOnItemClickListener(OnItemClickListener listener) {
//设置一个监听,一个回调的接口
this.mOnItemClickListener = listener;
}
public interface OnItemClickListener{
//条目
void onItemClick(int position);
}
public class InnerHolder extends RecyclerView.ViewHolder {
private int mPosition;
private final ImageView mImage;
private final TextView mContent;
private final TextView mPrice;
@ -96,24 +114,33 @@ public class StaggerAdapter extends RecyclerView.Adapter<StaggerAdapter.InnerHol
mContent = itemView.findViewById(R.id.tv_content);
mPrice = itemView.findViewById(R.id.tv_price);
}
public void setData(Good good) {
//开始设置数据
mContent.setText(good.getContent());
mPrice.setText(good.getPrice());
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//监听
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(mPosition);
}
}
});
}
public TextView getTvTitle() {
return mContent;
}
public TextView getTvCount() {
return mPrice;
}
public ImageView getIvGoods() {
return mImage;
}
public void setmPosition(int position){
this.mPosition=position;
}
}
// //实现瀑布流效果
// private void showStagger() {

@ -1,5 +1,6 @@
package com.android.activity.fragment;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
@ -14,11 +15,15 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.android.R;
import com.android.activity.GoodsDetailsActivity;
import com.android.activity.adapter.GoodsAdapter;
import com.android.activity.adapter.StaggerAdapter;
import com.android.bean.Good;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.utils.eventBus.EventMsg;
import org.greenrobot.eventbus.EventBus;
@ -41,11 +46,10 @@ public class GoodsTypeFragment extends Fragment {
private static final String ARG_TEXT = "param1";
private static final String ARG_GOODS = "goodsTypeList";
private ArrayList<Good> goodArrayList;
private EventMsg<Good> eventMsg;
private ArrayList<Good> typeGoodList;
private RecyclerView recyclerView;
private StaggerAdapter goodsAdapter;
// private GoodsAdapter goodsAdapter;
private StaggerAdapter staggerAdapter;
private User user;
View rootView;
@ -100,11 +104,7 @@ public class GoodsTypeFragment extends Fragment {
recyclerView = rootView.findViewById(R.id.rl_goods_show);
if (goodArrayList != null){
Log.d("TAG", "initView");
goodsAdapter = new StaggerAdapter(typeGoodList,getContext());
// goodsAdapter = new GoodsAdapter(typeGoodList,getContext());
// recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// recyclerView.setAdapter(goodsAdapter);
staggerAdapter = new StaggerAdapter(typeGoodList,getContext());
//准备布局管理器
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
//设置布局管理器的方向
@ -112,18 +112,35 @@ public class GoodsTypeFragment extends Fragment {
//设置布局管理器到RecyclerView中
recyclerView.setLayoutManager(layoutManager);
//设置适配器
recyclerView.setAdapter(goodsAdapter);
recyclerView.setAdapter(staggerAdapter);
//设置监听事件
initListener();
}
// TextView view = rootView.findViewById(R.id.tv_goods);
// view.setText(goodArrayList.get(1).getUsername());
}
private void initListener() {
staggerAdapter.setOnItemClickListener(new StaggerAdapter.OnItemClickListener() {
@Override
public void onItemClick(int position) {
//监听的各种操作写在这里
Toast.makeText(getActivity(), "我点击了第"+position+"item", Toast.LENGTH_SHORT).show();
Good goods = typeGoodList.get(position);
//Eventbus发生事件
EventBus.getDefault().postSticky(goods);
//intent跳转
Intent intent = new Intent(getActivity(), GoodsDetailsActivity.class);
startActivity(intent);
}
});
}
@Override
public void onStart() {
EventBus.getDefault().register(this);
super.onStart();
@ -143,11 +160,4 @@ public class GoodsTypeFragment extends Fragment {
super.onDestroy();
}
@Subscribe(sticky = true,threadMode = ThreadMode.MAIN)
public void onReceiveMsg(EventMsg eventMsg){
this.eventMsg = eventMsg;
// TextView view = rootView.findViewById(R.id.tv_goods);
// view.setText(eventMsg.getMsg());
}
}

@ -21,6 +21,7 @@ import com.android.bean.Good;
import com.android.bean.GoodRecords;
import com.android.bean.GoodsType;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.model.goods.GoodsListener;
import com.android.model.goods.GoodsModelimpl;
import com.android.utils.eventBus.EventMsg;
@ -28,6 +29,8 @@ import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
@ -45,6 +48,7 @@ public class HomePageFragment extends Fragment implements View.OnClickListener,
private List<Good> goodList;
private View rootView;
private GoodsTypeFSAdapter goodsTypeFSAdapter;
private User user;
private ViewPager2 viewPager;
@ -59,10 +63,16 @@ public class HomePageFragment extends Fragment implements View.OnClickListener,
@Override
public void onCreate(Bundle savedInstanceState) {
EventBus.getDefault().register(this);
super.onCreate(savedInstanceState);
}
@Override
public void onStop() {
EventBus.getDefault().unregister(this);
super.onStop();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -76,7 +86,12 @@ public class HomePageFragment extends Fragment implements View.OnClickListener,
}
private void initGoodsTypeData() {
goodsModelimpl = new GoodsModelimpl();
if (user != null){
goodsModelimpl = new GoodsModelimpl(user);
}else {
goodsModelimpl = new GoodsModelimpl();
}
goodsModelimpl.getAllGood(this);
goodsModelimpl.getAllGoodsType(this);
new Handler().postDelayed(new Runnable() {
@ -113,8 +128,6 @@ public class HomePageFragment extends Fragment implements View.OnClickListener,
fragments.add(GoodsTypeFragment.newInstance(goodsTypeList.get(i).getId(), goodList));
//EventBus发布消息
// EventBus.getDefault().postSticky(new EventMsg<>(goodsTypeList.get(i).getType(),200,goodList));
}
goodsTypeFSAdapter = new GoodsTypeFSAdapter(getActivity().getSupportFragmentManager(), getLifecycle(),fragments);
@ -126,8 +139,15 @@ public class HomePageFragment extends Fragment implements View.OnClickListener,
}
@Override
public void onClick(View v) {
}
@Subscribe(threadMode = ThreadMode.POSTING,sticky = true)
public void getLoginUser(ResponseData<User> responseData){
this.user = responseData.getData();
}
}

@ -4,11 +4,19 @@ import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.R;
import com.android.bean.ResponseData;
import com.android.bean.User;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/**
* A simple {@link Fragment} subclass.
@ -16,6 +24,9 @@ import com.android.R;
* create an instance of this fragment.
*/
public class MyPageFragment extends Fragment {
private View rootView;
private TextView textView;
private ResponseData<User> userResponseData;
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
@ -30,6 +41,20 @@ public class MyPageFragment extends Fragment {
// Required empty public constructor
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onStop() {
super.onStop();
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
@ -48,9 +73,22 @@ public class MyPageFragment extends Fragment {
return fragment;
}
@Override
public void onDestroy() {
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
super.onDestroy();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
@ -61,6 +99,16 @@ public class MyPageFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_my_page, container, false);
rootView = inflater.inflate(R.layout.fragment_my_page, container, false);
textView = rootView.findViewById(R.id.tv_my);
return rootView;
}
@Subscribe(threadMode = ThreadMode.POSTING,sticky = true)
public void getLoginUser(ResponseData<User> responseData){
this.userResponseData = responseData;
}
}

@ -13,19 +13,23 @@ import lombok.NoArgsConstructor;
public class User implements Serializable {
@SerializedName("id")
private Integer id;
private Long id;
@SerializedName("username")
private String userName;
private String code;
private String phone;
@SerializedName("avatar")
private String avatar;
@SerializedName("appKey")
private String appKey;
@SerializedName("money")
private Integer money;
public Integer getId() {
public Long getId() {
return id;
}
public void setId(Integer id) {
public void setId(Long id) {
this.id = id;
}

@ -17,14 +17,14 @@ import retrofit2.http.QueryMap;
public interface GoodsHttp_interface {
@GET("tran/goods/type")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4",
"appSecret:76387a99d8b52fad54b94bea1118262573381"})
@Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<List<GoodsType>>> sendGetAllGoodsType();
@GET("tran/goods/all")
@Headers({"appId:e843562fefa144bf808a9621b107b3a4",
"appSecret:76387a99d8b52fad54b94bea1118262573381"})
Observable<ResponseData<GoodRecords>> sendGetAllGood(@Query("userId") Integer userId,
@Headers({"appId:b34ac21286ae45938add627b418a4871",
"appSecret:67526def9de11d4a64f5e80e60ed3372eea69"})
Observable<ResponseData<GoodRecords>> sendGetAllGood(@Query("userId") Long userId,
@QueryMap Map<String, Object> map
);

@ -1,5 +1,6 @@
package com.android.model.goods;
import android.net.Uri;
import android.util.ArrayMap;
import android.util.Log;
@ -7,6 +8,7 @@ import com.android.bean.Good;
import com.android.bean.GoodRecords;
import com.android.bean.GoodsType;
import com.android.bean.ResponseData;
import com.android.bean.User;
import com.android.model.login.LoginListener;
import java.util.List;
@ -23,9 +25,16 @@ import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class GoodsModelimpl implements GoodsModel{
private User user;
private String TAG ="GoodsModelimpl";
public GoodsModelimpl(User user) {
this.user = user;
}
public GoodsModelimpl() {
}
@Override
public void getAllGoodsType(GoodsListener goodsListener) {
@ -50,7 +59,6 @@ public class GoodsModelimpl implements GoodsModel{
@Override
public void onNext(@NonNull ResponseData<List<GoodsType>> listResponseData) {
Log.e(TAG,listResponseData.getMsg());
goodsListener.onGetAllGoodsType(listResponseData);
}
@ -77,8 +85,10 @@ public class GoodsModelimpl implements GoodsModel{
retrofit.create(GoodsHttp_interface.class);
Map<String, Object> map = new ArrayMap<>();
Observable<ResponseData<GoodRecords>> observable
= httpInterface.sendGetAllGood(17, map);
= httpInterface.sendGetAllGood(6l, map);
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@ -91,7 +101,6 @@ public class GoodsModelimpl implements GoodsModel{
@Override
public void onNext(@NonNull ResponseData<GoodRecords> listResponseData) {
goodsListener.onGetAllGoodSuccess(listResponseData);
Log.e("1111",listResponseData.getData().getRecords().get(1).getUsername());
}
@Override

@ -37,8 +37,6 @@ public class LoginModelImpl implements LoginModel{
User user = new User();
user.setCode(phoneCode);
user.setPhone(account);
Log.e("TAG",phoneCode);
Log.e("TAG",account);
Observable<ResponseData<User>> observable = request.login(user);
observable
@ -53,6 +51,7 @@ public class LoginModelImpl implements LoginModel{
@Override
public void onNext(@NonNull ResponseData<User> userResponseData) {
loginListener.onLoginSuccess(userResponseData);
Log.e("login",userResponseData.getMsg());
}
@Override

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="8dp"
android:height="8dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">

@ -0,0 +1,16 @@
<?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=".activity.GoodsDetailsActivity">
<TextView
android:id="@+id/tv_goods_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="商品详细页面"
android:gravity="center"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -12,6 +12,7 @@
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
/>

@ -43,7 +43,8 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_acc"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:text="14777361004"/>
</com.google.android.material.textfield.TextInputLayout>
<RelativeLayout

@ -7,6 +7,7 @@
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/tv_my"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="my" />

@ -1,39 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="20dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:padding="8dp"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginRight="5dp"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="#68E3CC9F"
>
<ImageView
android:id="@+id/iv_goods"
android:layout_width="120dp"
android:layout_height="90dp"
android:layout_width="match_parent"
android:layout_height="128dp"
android:scaleType="centerCrop"
>
</ImageView>
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_goods"
android:layout_below="@id/iv_goods"
android:paddingTop="8dp"
android:paddingLeft="16dp"
android:paddingBottom="4dp"
android:textColor="#E64A19"
android:textSize="18sp"
android:textStyle="bold"
android:text="手机"
android:textSize="20dp"
android:layout_marginTop="10dp">
>
</TextView>
<TextView
android:id="@+id/tv_subtitle"
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_title"
android:paddingLeft="8dp"
android:paddingBottom="4dp"
android:text="描述"
android:textColor="@android:color/secondary_text_light" />
<TextView
android:id="@+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_title"
android:layout_below="@id/tv_subtitle"
android:layout_marginTop="8dp"
android:text="价格: "
android:textSize="15dp"
android:textColor="#FF8F03"
android:layout_marginTop="15dp">
</TextView>
android:textSize="15dp"></TextView>
<TextView
android:id="@+id/tv_count"
android:layout_width="wrap_content"
@ -44,11 +69,17 @@
android:text="1000"
android:textColor="#FF8F03">
</TextView>
<!-- <Button-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content">-->
<!-- </Button>-->
<Button
android:id="@+id/bt_add_car"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_title"
android:layout_marginStart="306dp"
android:background="@drawable/add_shopping_cart_24"
android:clickable="true">
</Button>
</RelativeLayout>

@ -1,61 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey">
<RelativeLayout
android:layout_width="200dp"
android:layout_height="280dp"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="15dp"
android:background="@color/white">
<ImageView
android:id="@+id/iv_image"
app:cardUseCompatPadding="true"
app:cardCornerRadius="10dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tv_content"
android:layout_width="180dp"
android:layout_height="25dp"
android:layout_below="@+id/iv_image"
android:layout_marginStart="13dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layout_height="280dp"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="15dp"
android:textSize="20dp" />
<TextView
android:id="@+id/str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_content"
android:layout_alignLeft="@+id/tv_content"
android:text="价格: "
android:textColor="@color/red" />
<TextView
android:id="@+id/tv_price"
android:layout_width="100dp"
android:layout_height="18dp"
android:layout_below="@+id/tv_content"
android:layout_toRightOf="@+id/str"
android:textColor="@color/red" />
<!-- <TextView-->
<!-- android:id="@+id/iv_delete"-->
<!-- android:layout_width="30dp"-->
<!-- android:layout_height="30dp"-->
<!-- android:layout_alignEnd="@+id/tv_content"-->
<!-- android:layout_alignBottom="@+id/tv_price"-->
<!-- android:src="@drawable/ic_baseline_close_24" />-->
</RelativeLayout>
</RelativeLayout>
android:background="@color/white">
<ImageView
android:id="@+id/iv_image"
android:layout_width="200dp"
android:layout_height="200dp"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tv_content"
android:layout_width="180dp"
android:layout_height="25dp"
android:layout_below="@+id/iv_image"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="15dp"
android:textSize="20dp" />
<TextView
android:id="@+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_below="@+id/tv_content"
android:textColor="@color/red" />
<TextView
android:id="@+id/str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_content"
android:layout_toRightOf="@+id/tv_price"
android:text="@string/moneyType"
android:textColor="@color/red" />
<Button
android:id="@+id/elevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="加入购物车"
style="Filled button"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="32dp"
/>
<!-- <Button-->
<!-- android:id="@+id/bt_buy_now"-->
<!-- android:layout_width="64dp"-->
<!-- android:layout_height="32dp"-->
<!-- android:text="立即购买"-->
<!-- android:textColor="@color/teal_200"-->
<!-- android:backgroundTint="@color/grey"-->
<!-- android:layout_below="@id/tv_content"-->
<!-- android:layout_marginStart="132dp"-->
<!-- />-->
<!-- <Button-->
<!-- android:id="@+id/bt_add_to_cars"-->
<!-- android:layout_width="64dp"-->
<!-- android:layout_height="32dp"-->
<!-- android:text="加入购物车"-->
<!-- android:textColor="@color/teal_200"-->
<!-- android:backgroundTint="@color/grey"-->
<!-- android:layout_below="@id/tv_content"-->
<!-- android:layout_marginStart="64dp"-->
<!-- />-->
<!-- <TextView-->
<!-- android:id="@+id/iv_delete"-->
<!-- android:layout_width="30dp"-->
<!-- android:layout_height="30dp"-->
<!-- android:layout_alignEnd="@+id/tv_content"-->
<!-- android:layout_alignBottom="@+id/tv_price"-->
<!-- android:src="@drawable/ic_baseline_close_24" />-->
</RelativeLayout>
</androidx.cardview.widget.CardView>

@ -2,5 +2,6 @@
<string name="app_name">Android_Couser_Design</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="moneyType"></string>
</resources>
Loading…
Cancel
Save