liuyuchen_part
yuchen 6 months ago
parent e018bce351
commit cb162566ed

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="NullableNotNullManager">
@ -182,6 +183,13 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="1.0" />
</ProjectState>
</option>
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">

@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
<component name="VcsProjectSettings">
<option name="detectVcsMappingsAutomatically" value="false" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -36,13 +36,18 @@ android {
}
dependencies {
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.13.2'
// Material Design
implementation 'com.google.android.material:material:1.9.0'
// AndroidX
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.20"

@ -2,6 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.startsmake.llrisetabbardemo">
<!-- 添加相机权限,新添加 -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@ -33,9 +39,29 @@
<activity
android:name=".activity.ForgotPasswordActivity"
android:exported="false" />
<!-- 搜索页面 -->
<activity
android:name=".activity.SearchActivity"
android:exported="false" />
<!-- 搜索结果页面 -->
<activity
android:name=".activity.ChatActivity"
android:name=".activity.SearchResultsActivity"
android:exported="false" />
<!-- 添加FileProvider支持新添加摄像头功能 -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
</manifest>

@ -1,84 +0,0 @@
package com.startsmake.llrisetabbardemo.adapter;
import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.startsmake.llrisetabbardemo.R;
import java.util.List;
public class ImageAdapter extends BaseAdapter {
private Context context;
private List<Uri> imageUris;
private static final int MAX_IMAGES = 9;
public ImageAdapter(Context context, List<Uri> imageUris) {
this.context = context;
this.imageUris = imageUris;
}
@Override
public int getCount() {
return Math.min(imageUris.size() + 1, MAX_IMAGES);
}
@Override
public Object getItem(int position) {
if (position < imageUris.size()) {
return imageUris.get(position);
}
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_image, parent, false);
holder = new ViewHolder();
holder.imageView = convertView.findViewById(R.id.imageView);
holder.deleteButton = convertView.findViewById(R.id.btnDelete);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (position < imageUris.size()) {
// 显示已选择的图片
Uri imageUri = imageUris.get(position);
Glide.with(context)
.load(imageUri)
.placeholder(android.R.drawable.ic_menu_gallery) // 使用系统图标作为占位符
.into(holder.imageView);
holder.deleteButton.setVisibility(View.VISIBLE);
holder.deleteButton.setOnClickListener(v -> {
imageUris.remove(position);
notifyDataSetChanged();
});
} else {
// 显示添加按钮
holder.imageView.setImageResource(android.R.drawable.ic_input_add); // 使用系统图标
holder.deleteButton.setVisibility(View.GONE);
}
return convertView;
}
static class ViewHolder {
ImageView imageView;
ImageView deleteButton;
}
}

@ -1,15 +1,48 @@
package com.startsmake.llrisetabbardemo.fragment;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
// 改为 AndroidX
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.startsmake.llrisetabbardemo.R;
import com.startsmake.llrisetabbardemo.adapter.SearchAdapter;
import com.startsmake.llrisetabbardemo.activity.SearchActivity;
import com.startsmake.llrisetabbardemo.activity.SearchResultsActivity;
import com.startsmake.llrisetabbardemo.model.Product;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* User:Shine
@ -18,9 +51,424 @@ import com.startsmake.llrisetabbardemo.R;
*/
public class HomeFragment extends Fragment {
private EditText searchEditText;
private ImageButton cameraButton;
private TextView homeSearchButton;
// 首页商品展示相关
private RecyclerView homeProductsRecyclerView;
private TextView homeNoProductsText;
private LinearLayout defaultContent;
// 导航栏按钮
private RadioButton tabFollow;
private TextView tabRecommend, tabNew, tabStudy, tabLiving;
// 随机标签相关
private List<String> randomKeywords;
private Handler handler;
private Runnable keywordRunnable;
private static final long KEYWORD_CHANGE_INTERVAL = 3000;
private static final int CAMERA_REQUEST_CODE = 101;
private static final int CAMERA_PERMISSION_REQUEST_CODE = 102;
private String currentPhotoPath;
private List<Product> productList;
private SearchAdapter searchAdapter;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_home, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViews(view);
initSearchData();
initRandomKeywords();
setupNavigationButtons();
startKeywordRotation();
// 默认显示推荐内容
showRandomRecommendations();
tabRecommend.setTextColor(0xffff6b35);
}
private void initViews(View view) {
searchEditText = view.findViewById(R.id.search_edit_text);
cameraButton = view.findViewById(R.id.camera_button);
homeSearchButton = view.findViewById(R.id.home_search_button);
// 首页商品展示相关视图
homeProductsRecyclerView = view.findViewById(R.id.home_products_recycler_view);
homeNoProductsText = view.findViewById(R.id.home_no_products_text);
defaultContent = view.findViewById(R.id.default_content);
// 初始化导航栏按钮
tabFollow = view.findViewById(R.id.tab_follow);
tabRecommend = view.findViewById(R.id.tab_recommend);
tabNew = view.findViewById(R.id.tab_new);
tabStudy = view.findViewById(R.id.tab_study);
tabLiving = view.findViewById(R.id.tab_living);
// 设置首页商品RecyclerView
setupHomeProductsRecyclerView();
searchEditText.setOnClickListener(v -> {
Intent intent = new Intent(getActivity(), SearchActivity.class);
startActivity(intent);
});
homeSearchButton.setOnClickListener(v -> {
performHomeSearch();
});
cameraButton.setOnClickListener(v -> {
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
openCamera();
} else {
requestPermissions(new String[]{Manifest.permission.CAMERA}, CAMERA_PERMISSION_REQUEST_CODE);
}
});
}
// 设置首页商品RecyclerView
private void setupHomeProductsRecyclerView() {
homeProductsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
searchAdapter = new SearchAdapter(new ArrayList<>());
homeProductsRecyclerView.setAdapter(searchAdapter);
}
// 设置导航栏按钮点击事件
private void setupNavigationButtons() {
// 关注按钮
tabFollow.setOnClickListener(v -> {
resetTabColors();
tabFollow.setTextColor(0xffff6b35);
showFollowedProducts();
});
// 推荐按钮
tabRecommend.setOnClickListener(v -> {
resetTabColors();
tabRecommend.setTextColor(0xffff6b35);
showRandomRecommendations();
});
// 新发布按钮
tabNew.setOnClickListener(v -> {
resetTabColors();
tabNew.setTextColor(0xffff6b35);
showNewProducts();
});
// 学习资料按钮
tabStudy.setOnClickListener(v -> {
resetTabColors();
tabStudy.setTextColor(0xffff6b35);
showStudyProducts();
});
// 生活用品按钮
tabLiving.setOnClickListener(v -> {
resetTabColors();
tabLiving.setTextColor(0xffff6b35);
showLifeProducts();
});
}
// 重置所有标签颜色为未选中状态
private void resetTabColors() {
tabFollow.setTextColor(0xff666666);
tabRecommend.setTextColor(0xff666666);
tabNew.setTextColor(0xff666666);
tabStudy.setTextColor(0xff666666);
tabLiving.setTextColor(0xff666666);
}
// 显示随机推荐商品
private void showRandomRecommendations() {
if (productList == null || productList.isEmpty()) {
showNoProducts();
return;
}
List<Product> shuffledList = new ArrayList<>(productList);
Collections.shuffle(shuffledList);
int count = Math.min(6, shuffledList.size());
List<Product> randomProducts = shuffledList.subList(0, count);
showHomeProducts(randomProducts);
Toast.makeText(requireContext(), "为您推荐", Toast.LENGTH_SHORT).show();
}
// 显示新发布商品
private void showNewProducts() {
List<Product> newProducts = new ArrayList<>();
for (Product product : productList) {
if (Integer.parseInt(product.getId()) > 3) {
newProducts.add(product);
}
}
if (newProducts.isEmpty()) {
showNoProducts();
} else {
showHomeProducts(newProducts);
Toast.makeText(requireContext(), "新发布商品", Toast.LENGTH_SHORT).show();
}
}
// 显示学习资料类商品
private void showStudyProducts() {
List<Product> studyProducts = new ArrayList<>();
for (Product product : productList) {
if ("学习资料".equals(product.getCategory())) {
studyProducts.add(product);
}
}
if (studyProducts.isEmpty()) {
showNoProducts();
} else {
showHomeProducts(studyProducts);
Toast.makeText(requireContext(), "学习资料", Toast.LENGTH_SHORT).show();
}
}
// 显示生活用品类商品
private void showLifeProducts() {
List<Product> lifeProducts = new ArrayList<>();
for (Product product : productList) {
if ("生活用品".equals(product.getCategory())) {
lifeProducts.add(product);
}
}
if (lifeProducts.isEmpty()) {
showNoProducts();
} else {
showHomeProducts(lifeProducts);
Toast.makeText(requireContext(), "生活用品", Toast.LENGTH_SHORT).show();
}
}
// 显示关注用户的商品
private void showFollowedProducts() {
List<Product> followedProducts = new ArrayList<>();
if (productList.size() >= 2) {
followedProducts.add(productList.get(0));
followedProducts.add(productList.get(1));
}
if (followedProducts.isEmpty()) {
showNoProducts();
Toast.makeText(requireContext(), "您还没有关注任何用户", Toast.LENGTH_SHORT).show();
} else {
showHomeProducts(followedProducts);
Toast.makeText(requireContext(), "关注用户的商品", Toast.LENGTH_SHORT).show();
}
}
// 在首页显示商品
private void showHomeProducts(List<Product> products) {
searchAdapter.updateData(products);
homeProductsRecyclerView.setVisibility(View.VISIBLE);
homeNoProductsText.setVisibility(View.GONE);
defaultContent.setVisibility(View.GONE);
}
// 显示暂无商品
private void showNoProducts() {
homeProductsRecyclerView.setVisibility(View.GONE);
homeNoProductsText.setVisibility(View.VISIBLE);
defaultContent.setVisibility(View.GONE);
}
// 显示默认内容
private void showDefaultContent() {
homeProductsRecyclerView.setVisibility(View.GONE);
homeNoProductsText.setVisibility(View.GONE);
defaultContent.setVisibility(View.VISIBLE);
}
// 初始化随机标签列表
private void initRandomKeywords() {
randomKeywords = Arrays.asList(
"Java编程教材", "Python入门书籍", "高等数学课本", "英语四级真题", "考研政治资料", "计算机专业课", "电路分析教程", "机械制图教材", "经济学原理", "心理学导论", "设计素描本", "专业课程笔记","二手笔记本电脑", "机械键盘", "无线鼠标", "蓝牙耳机", "平板电脑", "智能手机", "充电宝", "U盘硬盘", "显示器", "路由器", "相机镜头", "游戏手柄", "收纳箱", "穿衣镜",
"瑜伽垫", "体重秤", "电风扇", "暖手宝", "床上桌", "衣柜", "鞋架", "晾衣架","羽毛球拍", "篮球足球", "滑板轮滑", "吉他乐器",
"画笔画具", "围棋象棋", "游泳装备", "健身器材", "登山背包", "帐篷睡袋", "摄影三脚架", "书法字帖"
);
handler = new Handler();
}
// 开始标签轮换
private void startKeywordRotation() {
keywordRunnable = new Runnable() {
@Override
public void run() {
if (randomKeywords != null && !randomKeywords.isEmpty()) {
Collections.shuffle(randomKeywords);
String randomKeyword = randomKeywords.get(0);
searchEditText.setHint(randomKeyword);
}
handler.postDelayed(this, KEYWORD_CHANGE_INTERVAL);
}
};
handler.post(keywordRunnable);
}
// 首页搜索功能
private void performHomeSearch() {
String currentHint = searchEditText.getHint().toString();
String defaultHint = getResources().getString(R.string.search_hint);
if (!currentHint.equals(defaultHint) && randomKeywords.contains(currentHint)) {
Intent intent = new Intent(getActivity(), SearchResultsActivity.class);
intent.putExtra("search_query", currentHint);
startActivity(intent);
} else {
Intent intent = new Intent(getActivity(), SearchActivity.class);
startActivity(intent);
}
}
private void initSearchData() {
productList = new ArrayList<>();
productList.add(new Product("1", "Java编程思想", "计算机专业教材", "学习资料", 45.0, ""));
productList.add(new Product("2", "高等数学教材", "大学数学课本", "学习资料", 30.0, ""));
productList.add(new Product("3", "笔记本电脑", "二手联想笔记本", "数码产品", 1200.0, ""));
productList.add(new Product("4", "台灯", "护眼学习台灯", "生活用品", 25.0, ""));
productList.add(new Product("5", "Python入门", "编程学习书籍", "学习资料", 35.0, ""));
productList.add(new Product("6", "数据结构与算法", "计算机专业书籍", "学习资料", 40.0, ""));
productList.add(new Product("7", "水杯", "保温水杯", "生活用品", 20.0, ""));
productList.add(new Product("8", "插排", "多功能插排", "生活用品", 35.0, ""));
}
// 原有的搜索方法保持不变
private void performSearch() {
String query = searchEditText.getText().toString().trim();
if (!query.isEmpty()) {
hideKeyboard();
List<Product> searchResults = searchProducts(query);
if (searchResults.isEmpty()) {
// 这里使用原有的搜索结果显示逻辑
showNoResults();
} else {
// 这里使用原有的搜索结果显示逻辑
showSearchResults(searchResults);
}
} else {
showDefaultContent();
}
}
// 原有的搜索结果显示方法
private void showSearchResults(List<Product> results) {
// 这里使用原有的搜索结果RecyclerView
// searchAdapter.updateData(results);
// searchResultsRecyclerView.setVisibility(View.VISIBLE);
// noResultsText.setVisibility(View.GONE);
// defaultContent.setVisibility(View.GONE);
}
private void showNoResults() {
// 原有的无结果显示逻辑
// searchResultsRecyclerView.setVisibility(View.GONE);
// noResultsText.setVisibility(View.VISIBLE);
// defaultContent.setVisibility(View.GONE);
}
private List<Product> searchProducts(String keyword) {
List<Product> results = new ArrayList<>();
for (Product product : productList) {
if (product.getName().toLowerCase().contains(keyword.toLowerCase()) ||
product.getDescription().toLowerCase().contains(keyword.toLowerCase()) ||
product.getCategory().toLowerCase().contains(keyword.toLowerCase())) {
results.add(product);
}
}
return results;
}
// 隐藏软键盘的方法
private void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) requireContext().getSystemService(Context.INPUT_METHOD_SERVICE);
View currentFocus = requireActivity().getCurrentFocus();
if (currentFocus != null) {
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == CAMERA_PERMISSION_REQUEST_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
openCamera();
} else {
Toast.makeText(requireContext(), "需要相机权限才能拍照搜索", Toast.LENGTH_SHORT).show();
}
}
}
private void openCamera() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(requireActivity().getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
Toast.makeText(requireContext(), "创建文件失败", Toast.LENGTH_SHORT).show();
}
if (photoFile != null) {
currentPhotoPath = photoFile.getAbsolutePath();
Uri photoURI = FileProvider.getUriForFile(requireContext(),
requireContext().getPackageName() + ".fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, CAMERA_REQUEST_CODE);
}
} else {
Toast.makeText(requireContext(), "未找到相机应用", Toast.LENGTH_SHORT).show();
}
}
private File createImageFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = requireContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
return File.createTempFile(
imageFileName,
".jpg",
storageDir
);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
if (currentPhotoPath != null) {
Toast.makeText(requireContext(), "拍照成功,开始搜索...", Toast.LENGTH_SHORT).show();
searchEditText.setText("图片搜索中...");
performSearch();
}
}
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (handler != null && keywordRunnable != null) {
handler.removeCallbacks(keywordRunnable);
}
}
}

@ -1,65 +1,26 @@
package com.startsmake.llrisetabbardemo.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
// 改为 AndroidX
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.startsmake.llrisetabbardemo.R;
import com.startsmake.llrisetabbardemo.activity.ChatActivity;
import com.startsmake.llrisetabbardemo.adapter.MessageAdapter;
import com.startsmake.llrisetabbardemo.model.MessageItem;
import java.util.ArrayList;
import java.util.List;
/**
* User:Shine
* Date:2015-10-20
* Description:
*/
public class MessageFragment extends Fragment {
private RecyclerView rvMessageList;
private MessageAdapter messageAdapter;
private List<MessageItem> messageList;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_message, container, false);
initView(view);
initData();
return view;
}
private void initView(View view) {
rvMessageList = view.findViewById(R.id.rvMessageList);
rvMessageList.setLayoutManager(new LinearLayoutManager(getContext()));
}
private void initData() {
messageList = new ArrayList<>();
// 添加消息数据 - 所有头像都使用白色背景
messageList.add(new MessageItem("通知消息", "红包到账提醒", "刚刚", 0, true));
messageList.add(new MessageItem("互动消息", "还没有新通知~", "", 0, false));
messageList.add(new MessageItem("闲鱼精选", "[347条] 关注的宝贝上新捡漏...", "6小时前", 347, false));
messageList.add(new MessageItem("刑事组之虎", "快给ta一个评价吧", "04-19", 0, false));
messageList.add(new MessageItem("卖家小助手", "开启急速转卖通道!", "05-25", 0, true));
messageList.add(new MessageItem("豫中玩具批…", "[我完成了评价]", "04-18", 0, false));
messageAdapter = new MessageAdapter(getContext(), messageList);
rvMessageList.setAdapter(messageAdapter);
// 添加点击监听
messageAdapter.setOnItemClickListener(new MessageAdapter.OnItemClickListener() {
@Override
public void onItemClick(MessageItem item) {
// 跳转到聊天页面
Intent intent = new Intent(getActivity(), ChatActivity.class);
intent.putExtra("chat_title", item.getTitle());
startActivity(intent);
}
});
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_message, container, false);
}
}

@ -1,204 +0,0 @@
package com.startsmake.llrisetabbardemo.fragment;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.startsmake.llrisetabbardemo.R;
import com.startsmake.llrisetabbardemo.activity.MainActivity;
import com.startsmake.llrisetabbardemo.adapter.ImageAdapter;
import model.Item;
import java.util.ArrayList;
import java.util.List;
public class PublishFragment extends Fragment {
private static final int REQUEST_CODE_PICK_IMAGES = 1001;
private static final int MAX_IMAGE_COUNT = 9;
private EditText etTitle, etDescription, etPrice, etContact;
private Spinner spinnerCategory, spinnerLocation;
private GridView gridViewImages;
private Button btnPublish;
private ImageAdapter imageAdapter;
private List<Uri> selectedImages = new ArrayList<>();
public PublishFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_publish, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViews(view);
setupSpinners();
setupImageGrid();
setupClickListeners();
}
private void initViews(View view) {
etTitle = view.findViewById(R.id.etTitle);
etDescription = view.findViewById(R.id.etDescription);
etPrice = view.findViewById(R.id.etPrice);
etContact = view.findViewById(R.id.etContact);
spinnerCategory = view.findViewById(R.id.spinnerCategory);
spinnerLocation = view.findViewById(R.id.spinnerLocation);
gridViewImages = view.findViewById(R.id.gridViewImages);
btnPublish = view.findViewById(R.id.btnPublish);
}
private void setupSpinners() {
String[] categories = {"数码产品", "服装鞋帽", "家居日用", "图书文具", "美妆个护", "运动户外", "其他"};
ArrayAdapter<String> categoryAdapter = new ArrayAdapter<>(
requireContext(), android.R.layout.simple_spinner_item, categories);
categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerCategory.setAdapter(categoryAdapter);
String[] locations = {"北京", "上海", "广州", "深圳", "杭州", "成都", "武汉", "其他"};
ArrayAdapter<String> locationAdapter = new ArrayAdapter<>(
requireContext(), android.R.layout.simple_spinner_item, locations);
locationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerLocation.setAdapter(locationAdapter);
}
private void setupImageGrid() {
imageAdapter = new ImageAdapter(requireContext(), selectedImages);
gridViewImages.setAdapter(imageAdapter);
}
private void setupClickListeners() {
gridViewImages.setOnItemClickListener((parent, view, position, id) -> {
if (position == selectedImages.size() && selectedImages.size() < MAX_IMAGE_COUNT) {
openImagePicker();
}
});
btnPublish.setOnClickListener(v -> publishItem());
}
private void openImagePicker() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(Intent.createChooser(intent, "选择图片"), REQUEST_CODE_PICK_IMAGES);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_PICK_IMAGES && resultCode == Activity.RESULT_OK) {
if (data != null) {
if (data.getClipData() != null) {
int count = Math.min(data.getClipData().getItemCount(),
MAX_IMAGE_COUNT - selectedImages.size());
for (int i = 0; i < count; i++) {
Uri imageUri = data.getClipData().getItemAt(i).getUri();
selectedImages.add(imageUri);
}
} else if (data.getData() != null) {
selectedImages.add(data.getData());
}
imageAdapter.notifyDataSetChanged();
}
}
}
private void publishItem() {
String title = etTitle.getText().toString().trim();
String description = etDescription.getText().toString().trim();
String priceStr = etPrice.getText().toString().trim();
String contact = etContact.getText().toString().trim();
if (title.isEmpty()) {
Toast.makeText(requireContext(), "请输入商品标题", Toast.LENGTH_SHORT).show();
return;
}
if (description.isEmpty()) {
Toast.makeText(requireContext(), "请输入商品描述", Toast.LENGTH_SHORT).show();
return;
}
if (priceStr.isEmpty()) {
Toast.makeText(requireContext(), "请输入商品价格", Toast.LENGTH_SHORT).show();
return;
}
if (contact.isEmpty()) {
Toast.makeText(requireContext(), "请输入联系方式", Toast.LENGTH_SHORT).show();
return;
}
if (selectedImages.isEmpty()) {
Toast.makeText(requireContext(), "请至少上传一张图片", Toast.LENGTH_SHORT).show();
return;
}
try {
double price = Double.parseDouble(priceStr);
if (price <= 0) {
Toast.makeText(requireContext(), "价格必须大于0", Toast.LENGTH_SHORT).show();
return;
}
// 创建物品对象
Item item = new Item();
item.setTitle(title);
item.setDescription(description);
item.setPrice(price);
item.setContact(contact);
item.setCategory(spinnerCategory.getSelectedItem().toString());
item.setLocation(spinnerLocation.getSelectedItem().toString());
item.setPublishTime(System.currentTimeMillis());
item.setUserId("user_" + System.currentTimeMillis());
// 发布成功
Toast.makeText(requireContext(), "发布成功!", Toast.LENGTH_SHORT).show();
clearForm();
// 发布完成后自动返回首页
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).switchToHomeFragment();
}
} catch (NumberFormatException e) {
Toast.makeText(requireContext(), "请输入有效的价格", Toast.LENGTH_SHORT).show();
}
}
private void clearForm() {
etTitle.setText("");
etDescription.setText("");
etPrice.setText("");
etContact.setText("");
selectedImages.clear();
imageAdapter.notifyDataSetChanged();
spinnerCategory.setSelection(0);
spinnerLocation.setSelection(0);
}
}

@ -1,53 +0,0 @@
package model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Item implements Serializable {
private String id;
private String title;
private String description;
private double price;
private List<String> imageUrls;
private String category;
private String location;
private String contact;
private long publishTime;
private String userId;
public Item() {
imageUrls = new ArrayList<>();
}
// Getters and Setters
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getTitle() { return title; }
public void setTitle(String title) { this.title = title; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public double getPrice() { return price; }
public void setPrice(double price) { this.price = price; }
public List<String> getImageUrls() { return imageUrls; }
public void setImageUrls(List<String> imageUrls) { this.imageUrls = imageUrls; }
public String getCategory() { return category; }
public void setCategory(String category) { this.category = category; }
public String getLocation() { return location; }
public void setLocation(String location) { this.location = location; }
public String getContact() { return contact; }
public void setContact(String contact) { this.contact = contact; }
public long getPublishTime() { return publishTime; }
public void setPublishTime(long publishTime) { this.publishTime = publishTime; }
public String getUserId() { return userId; }
public void setUserId(String userId) { this.userId = userId; }
}

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#99000000" />
<corners android:radius="12dp" />
</shape>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<corners android:radius="8dp" />
<stroke
android:width="1dp"
android:color="#e0e0e0" />
</shape>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f0f0f0" />
<corners android:radius="4dp" />
<stroke
android:width="1dp"
android:color="#e0e0e0" />
</shape>

@ -1,6 +1,11 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<!-- 设置圆角半径 -->
<corners android:radius="20dp"/>
<!-- 背景颜色 -->
<solid android:color="@android:color/white"/>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 设置圆角半径 -->
<corners android:radius="20dp" />
<!-- 背景颜色 -->
<solid android:color="@android:color/white" />
</shape>

@ -1,14 +1,244 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fffaf0"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
<!-- 顶部搜索栏区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="首页"/>
android:background="#FFDD59"
android:orientation="vertical"
android:padding="10dp">
<!-- 搜索框 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2.5dp"
android:alpha="0.8"
android:background="@drawable/rounded_background1"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="8dp">
<!-- 搜索图标 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="1"
android:text="🔍"
android:textSize="16sp" />
<!-- 搜索输入框 -->
<EditText
android:id="@+id/search_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:alpha="1"
android:background="@null"
android:focusable="false"
android:focusableInTouchMode="false"
android:hint="搜索教材、数码、生活用品..."
android:inputType="none"
android:maxLines="1"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:singleLine="true"
android:textColor="#333333"
android:textColorHint="#999999"
android:textSize="14sp" />
<!-- 摄像头按钮 -->
<ImageButton
android:id="@+id/camera_button"
android:layout_width="23dp"
android:layout_height="24dp"
android:layout_marginStart="4dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="0.5dp"
android:scaleType="centerInside"
android:src="@android:drawable/ic_menu_camera"
android:contentDescription="拍照搜索" />
<!-- 搜索按钮 - 放在输入框外面右侧 -->
<TextView
android:id="@+id/home_search_button"
android:layout_width="50dp"
android:layout_height="27dp"
android:layout_marginStart="2dp"
android:layout_marginTop="0dp"
android:gravity="center"
android:text="搜索"
android:textColor="#333333"
android:textSize="14sp"
android:textStyle="bold"
android:clickable="true"
android:focusable="true" />
</LinearLayout>
</LinearLayout>
<!-- 导航标签区域 -->
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="65dp"
android:background="@android:color/white"
android:paddingVertical="8dp">
<LinearLayout
android:id="@+id/tab_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- 关注标签 -->
<RadioButton
android:id="@+id/tab_follow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="关注"
android:button="@null"
android:textColor="#ff6b35"
android:textSize="14sp"
android:textStyle="bold"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true" />
<!-- 推荐标签 -->
<TextView
android:id="@+id/tab_recommend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="推荐"
android:textColor="#666666"
android:textSize="14sp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true" />
<!-- 新发布标签 -->
<TextView
android:id="@+id/tab_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="新发布"
android:textColor="#666666"
android:textSize="14sp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true" />
<!-- 学习资料标签 -->
<TextView
android:id="@+id/tab_study"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="学习资料"
android:textColor="#666666"
android:textSize="14sp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true" />
<!-- 生活用品标签 -->
<TextView
android:id="@+id/tab_living"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="生活用品"
android:textColor="#666666"
android:textSize="14sp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true" />
</LinearLayout>
</HorizontalScrollView>
<!-- 在导航标签区域后面添加商品展示区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<!-- 商品展示区域 -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_products_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<!-- 暂无商品提示 -->
<TextView
android:id="@+id/home_no_products_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="暂无商品"
android:textColor="#666666"
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
<!-- 搜索结果RecyclerView -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_results_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<!-- 无结果提示 -->
<TextView
android:id="@+id/no_results_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="没有找到相关商品"
android:textSize="16sp"
android:textColor="#666666"
android:visibility="gone" />
<!-- 首页默认内容区域 -->
<LinearLayout
android:id="@+id/default_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:padding="16dp">
</LinearLayout>
</FrameLayout>

@ -1,60 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#f5f5f5">
android:orientation="vertical">
<!-- 标题栏 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@android:color/white"
android:elevation="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="消息"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="消息"
android:textSize="18sp"
android:textStyle="bold"
android:layout_centerInParent="true" />
</RelativeLayout>
<!-- 搜索栏 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/white"
android:paddingHorizontal="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/etSearch"
android:layout_width="match_parent"
android:layout_height="36dp"
android:background="@drawable/bg_search_edittext"
android:hint="搜索聊天记录/联系人/服务号"
android:paddingStart="40dp"
android:paddingEnd="16dp"
android:singleLine="true"
android:textSize="14sp" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@android:drawable/ic_menu_search"
android:layout_centerVertical="true"
android:layout_marginStart="12dp" />
</RelativeLayout>
<!-- 消息列表 -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvMessageList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp" />
</LinearLayout>
</FrameLayout>

@ -1,627 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f5f5f5">
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_gravity="center"
android:text="我的"/>
<!-- 顶部用户信息区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@color/white"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:id="@+id/iv_avatar"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/ic_default_avatar"
android:background="@drawable/circle_bg"
android:layout_marginEnd="16dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点击登录"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@color/black" />
<TextView
android:id="@+id/tv_user_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="省钱达人,精明购物"
android:textSize="12sp"
android:textColor="@color/gray"
android:layout_marginTop="4dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<TextView
android:id="@+id/tv_credit_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="信用极好"
android:textSize="10sp"
android:background="@drawable/credit_bg"
android:paddingHorizontal="8dp"
android:paddingVertical="2dp"
android:textColor="@color/white" />
<TextView
android:id="@+id/tv_member_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="省钱会员"
android:textSize="10sp"
android:background="@drawable/member_bg"
android:paddingHorizontal="8dp"
android:paddingVertical="2dp"
android:textColor="@color/white"
android:layout_marginStart="8dp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/iv_qr_code"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_qr_code"
android:layout_marginEnd="16dp" />
<ImageView
android:id="@+id/iv_settings"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_settings" />
</LinearLayout>
<!-- 数据统计区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@color/white"
android:orientation="horizontal"
android:layout_marginTop="8dp"
android:padding="16dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tv_want_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="想买"
android:textSize="12sp"
android:textColor="@color/gray"
android:layout_marginTop="4dp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="30dp"
android:background="#eeeeee"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tv_selling_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="在售"
android:textSize="12sp"
android:textColor="@color/gray"
android:layout_marginTop="4dp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="30dp"
android:background="#eeeeee"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tv_sold_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="已售"
android:textSize="12sp"
android:textColor="@color/gray"
android:layout_marginTop="4dp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="30dp"
android:background="#eeeeee"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tv_saved_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥0"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@color/green" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="已省钱"
android:textSize="12sp"
android:textColor="@color/gray"
android:layout_marginTop="4dp" />
</LinearLayout>
</LinearLayout>
<!-- 我的工具区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:layout_marginTop="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我的工具"
android:textSize="14sp"
android:textColor="@color/black"
android:padding="16dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="16dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_my_listings"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我发布的"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_purchase_history"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="购买记录"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_wishlist"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="心愿单"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_budget_tracker"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="预算追踪"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="16dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_price_alert"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="价格提醒"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_coupons"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="优惠券"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_help"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="帮助中心"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_more"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="更多"
android:textSize="12sp"
android:textColor="@color/gray" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- 推荐功能区 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="推荐功能"
android:textSize="14sp"
android:textColor="@color/black"
android:padding="16dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#eeeeee" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_invite_friends"
android:layout_marginEnd="12dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="邀请好友"
android:textSize="14sp"
android:textColor="@color/black" />
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_arrow_right" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#eeeeee" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_feedback"
android:layout_marginEnd="12dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="意见反馈"
android:textSize="14sp"
android:textColor="@color/black" />
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_arrow_right" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#eeeeee" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_about"
android:layout_marginEnd="12dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="关于BudgetFindly"
android:textSize="14sp"
android:textColor="@color/black" />
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_arrow_right" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#eeeeee" />
<LinearLayout
android:id="@+id/ll_logout"
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:gravity="center_vertical"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_logout"
android:layout_marginEnd="12dp"
android:color="#FF5722" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="退出登录"
android:textSize="14sp"
android:textColor="#FF5722" />
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_arrow_right"
android:color="#FF5722" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</FrameLayout>

@ -1,148 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:background="#f5f5f5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- 图片上传区域 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="上传图片"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<GridView
android:id="@+id/gridViewImages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3"
android:verticalSpacing="8dp"
android:horizontalSpacing="8dp"
android:stretchMode="columnWidth"
android:background="@drawable/bg_edittext"
android:padding="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="最多可上传9张图片"
android:textSize="12sp"
android:textColor="#666"
android:layout_marginTop="4dp"
android:layout_marginBottom="16dp" />
<!-- 商品信息区域 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="商品信息"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<EditText
android:id="@+id/etTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="商品标题"
android:maxLines="1"
android:background="@drawable/bg_edittext"
android:padding="12dp" />
<EditText
android:id="@+id/etDescription"
android:layout_width="match_parent"
android:layout_height="120dp"
android:hint="商品描述"
android:gravity="top"
android:maxLines="5"
android:background="@drawable/bg_edittext"
android:padding="12dp"
android:layout_marginTop="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<EditText
android:id="@+id/etPrice"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="价格"
android:inputType="numberDecimal"
android:background="@drawable/bg_edittext"
android:padding="12dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="元"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingStart="8dp"
android:paddingEnd="8dp" />
</LinearLayout>
<!-- 分类和位置 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<Spinner
android:id="@+id/spinnerCategory"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bg_edittext"
android:padding="8dp" />
<Spinner
android:id="@+id/spinnerLocation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:background="@drawable/bg_edittext"
android:padding="8dp" />
</LinearLayout>
<!-- 联系方式 -->
<EditText
android:id="@+id/etContact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="联系方式(微信/电话)"
android:maxLines="1"
android:background="@drawable/bg_edittext"
android:padding="12dp"
android:layout_marginTop="8dp" />
<!-- 发布按钮 -->
<Button
android:id="@+id/btnPublish"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="发布商品"
android:textSize="16sp"
android:textStyle="bold"
android:background="@drawable/bg_button_primary"
android:textColor="@android:color/white"
android:layout_marginTop="24dp" />
</LinearLayout>
</ScrollView>

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:padding="2dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:background="@drawable/bg_image_border" />
<ImageView
android:id="@+id/btnDelete"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:src="@android:drawable/ic_delete"
android:background="@drawable/bg_delete_button" />
</RelativeLayout>

@ -16,8 +16,5 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="gray">#FF9E9E9E</color>
<color name="green">#FF4CAF50</color>
<color name="logout_red">#FF5722</color>
<color name="comui_tab_text_color">#ff333333</color>
</resources>

@ -1,3 +1,4 @@
<resources>
<string name="app_name">LLRiseTabBarDemo</string>
<string name="search_hint">Searchforproducts</string>
</resources>

Loading…
Cancel
Save