You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.6 KiB
78 lines
2.6 KiB
package com.example.orangesale_04.fragment;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.Fragment;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
|
|
import com.example.orangesale_04.R;
|
|
import com.example.orangesale_04.activity.CategoryActivity;
|
|
import com.example.orangesale_04.entity.Product;
|
|
|
|
import java.util.Objects;
|
|
|
|
public class SetDetailFragment extends Fragment {
|
|
private View view;
|
|
private ImageView imageView,priceView;
|
|
private TextView nameText, priceText,contentText,CostText;
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n")
|
|
@Nullable
|
|
@Override
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
view = inflater.inflate(R.layout.categoty_detail_content, container, false);
|
|
if (view != null) {
|
|
init();
|
|
}
|
|
CategoryActivity categoryActivity = (CategoryActivity) getActivity();
|
|
categoryActivity.setOnChangeListener(new CategoryActivity.OnChangeListener() {
|
|
@Override
|
|
public void changeText(Product product) {
|
|
imageView.setBackgroundResource(product.getImageUrlId());
|
|
nameText.setText(product.getProductName());
|
|
priceText.setText(product.getProductPrice().toString());
|
|
|
|
priceView.setBackgroundResource(product.getPriceUrlIdUrlId());
|
|
contentText.setText(product.getProductContent().toString());
|
|
CostText.setText(product.getProductCost());
|
|
|
|
|
|
|
|
}
|
|
});
|
|
/* Objects.requireNonNull(categoryActivity).setOnChangeListener(product -> {
|
|
Log.i("sss", "onCreateView: " + product.getProductName());
|
|
imageView.setBackgroundResource(product.getImageUrlId());
|
|
nameText.setText(product.getProductName());
|
|
priceText.setText(product.getProductPrice().toString());
|
|
});
|
|
|
|
*/
|
|
return view;
|
|
}
|
|
|
|
/**
|
|
* 内容组件初始化
|
|
*/
|
|
private void init() {
|
|
imageView = view.findViewById(R.id.category_product_image);
|
|
nameText = view.findViewById(R.id.category_product_name);
|
|
priceText = view.findViewById(R.id.category_product_price);
|
|
|
|
priceView = view.findViewById(R.id.category_product_priceImage);
|
|
contentText = view.findViewById(R.id.category_product_content);
|
|
CostText = view.findViewById(R.id.category_product_cost);
|
|
}
|
|
|
|
}
|