Update layout parameters of view

本文介绍了一种更新Android应用中特定LinearLayout布局高度的方法。通过获取该布局的LayoutParams,并修改其height属性为屏幕高度的6%来实现自适应调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// suppose we want to update layout_height parameter of following layout
// <LinearLayout
//    android:id="@+id/categorySelectorBar"
//    android:orientation="horizontal"
//    android:layout_width="match_parent"
//    android:layout_height="@dimen/category_selector_bar_height"
//    android:layout_alignParentBottom="true"
//    android:background="@color/light_gray">
// </LinearLayout>

// Solution
ViewGroup.LayoutParams layoutParams = mCategorySelectorBar.getLayoutParams();
layoutParams.height = LayoutUtils.getNPercentOfScreenHeightInPixel(this, 0.06f);
mCategorySelectorBar.setLayoutParams(layoutParams);

FanHui.java::package com.videogo.ui.login; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.TextView; import com.videogo.openapi.EZOpenSDK; import ezviz.ezopensdk.R; import androidx.appcompat.app.AppCompatActivity; import java.util.Calendar; import java.util.Locale; import com.videogo.widget.TitleBar; import android.app.DatePickerDialog; public class FanHui extends AppCompatActivity { private static final String TAG = "EZPreview"; private String mAppKey; private String mDeviceSerial; private String mVerifyCode; private String mAccessToken; private int mCameraNo; private TextView mDateTextView; private int mSelectedYear, mSelectedMonth, mSelectedDay; private static final String KEY_APPKEY = "appkey"; private static final String KEY_SERIAL = "serial"; private static final String KEY_VERIFYCODE = "VerifyCode"; private static final String KEY_ACCESSTOKEN = "accessToken"; private static final String KEY_CAMERANO = "cameraNo"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ez_playback_list_page); extractParametersFromIntent(); final Calendar calendar = Calendar.getInstance(); mSelectedYear = calendar.get(Calendar.YEAR); mSelectedMonth = calendar.get(Calendar.MONTH); mSelectedDay = calendar.get(Calendar.DAY_OF_MONTH); // 设置日期显示模块 setupDatePicker(); View fanHui = findViewById(R.id.fanhui); fanHui.setOnClickListener(v -> finish()); Button huifangBtn = findViewById(R.id.fanhui); huifangBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 创建Intent跳转到FanHui活动 Intent intent = new Intent(FanHui.this, MainActivity.class); // 传递必要参数(可选) intent.putExtra("deviceSerial", mDeviceSerial); intent.putExtra("cameraNo", mCameraNo); intent.putExtra("accessToken", mAccessToken); intent.putExtra("appkey", mAppKey); intent.putExtra("verifyCode", mVerifyCode); startActivity(intent); } }); } private void setupDatePicker() { mDateTextView = findViewById(R.id.date_text); ImageButton datePickerButton = findViewById(R.id.date_picker_button); updateDateDisplay(); datePickerButton.setOnClickListener(v -> showDatePickerDialog()); } private void updateDateDisplay() { String formattedDate = String.format(Locale.getDefault(), "%d年%02d月%02d日", mSelectedYear, mSelectedMonth + 1, // 月份需要+1 mSelectedDay); mDateTextView.setText(formattedDate); } private void showDatePickerDialog() { DatePickerDialog datePickerDialog = new DatePickerDialog( this, (view, year, month, dayOfMonth) -> { // 更新日期 }, mSelectedYear, mSelectedMonth, mSelectedDay ); datePickerDialog.show(); } private void extractParametersFromIntent() { Bundle extras = getIntent().getExtras(); if (extras != null) { mAppKey = extras.getString(KEY_APPKEY, ""); mDeviceSerial = extras.getString(KEY_SERIAL, ""); mVerifyCode = extras.getString(KEY_VERIFYCODE, ""); mAccessToken = extras.getString(KEY_ACCESSTOKEN, ""); mCameraNo = extras.getInt(KEY_CAMERANO, 0); Log.d(TAG, "Received parameters:"); Log.d(TAG, "AppKey: " + mAppKey); Log.d(TAG, "DeviceSerial: " + mDeviceSerial); Log.d(TAG, "VerifyCode: " + mVerifyCode); Log.d(TAG, "AccessToken: " + mAccessToken); Log.d(TAG, "CameraNo: " + mCameraNo); } else { Log.e(TAG, "No parameters received from intent"); // 如果没有参数,可以显示错误信息并退出 // finish(); } } } FanHui代码的datepicker_layout.xml:<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/white" android:orientation="vertical" > <DatePicker android:id="@+id/dpPicker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:calendarViewShown="false" /> <View android:layout_width="wrap_content" android:layout_height="1dp" android:layout_below="@id/dpPicker" android:background="#e1e5e7" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/dpPicker" android:layout_centerHorizontal="true" android:layout_marginTop="1dp" android:gravity="center" android:orientation="horizontal" > <RelativeLayout android:id="@+id/YES" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="确定" android:layout_margin="10dp" android:textColor="@android:color/black" android:textSize="22sp" /> </RelativeLayout> <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#e1e5e7" /> <RelativeLayout android:id="@+id/NO" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_margin="10dp" android:text="取消" android:textColor="@android:color/black" android:textSize="22sp" /> </RelativeLayout> </LinearLayout> </RelativeLayout> WeatherInfoActivity.java:package com.jd.projects.wlw.weatherinfo; import static com.jd.projects.wlw.weatherinfo.AllInfoMap.KEY_SITE_INFO; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.DatePickerDialog; import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.view.Display; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.DatePicker; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Spinner; import android.widget.TextView; import android.widget.TimePicker; import com.jd.projects.wlw.DeviceMapActivity; import com.jd.projects.wlw.R; import com.jd.projects.wlw.bean.MapDataBean; import com.jd.projects.wlw.bean.new_webservice.MapDataBeanNew; import com.jd.projects.wlw.fragment.CureDataFragment; import com.jd.projects.wlw.fragment.HistoryDataFragment; import com.jd.projects.wlw.fragment.MonthDataFragment; import com.jd.projects.wlw.fragment.RealTimeFragment; import com.jd.projects.wlw.fragment.TjfxDataFragment; import com.jd.projects.wlw.update.Utils; import java.text.SimpleDateFormat; import java.util.Calendar; public class WeatherInfoActivity extends FragmentActivity implements OnClickListener { private LinearLayout layout_tqyb, layout_nyqx, layout_nyzx, layout_gdnq, layout_tjfx,layout_location; private ImageView image_ntqx, image_tqyb, image_nyzx, image_gdnq, image_tjfx; private Fragment mContent; public static MapDataBean realdata; // public static String asitename; private Calendar calendar = Calendar.getInstance(); private Context context; private ArrayAdapter<String> spinneradapter; private static final String[] m2 = {"空气温度", "空气湿度", "土壤温度1", "土壤温度2", "土壤温度3", "土壤湿度", "光照度", "蒸发量", "降雨量", "风速", "风向", "结露", "气压", "总辐射", "光合有效辐射"}; private static final String[] m1 = {"空气温度", "空气湿度", "土壤温度1", "土壤温度2", "土壤温度3", "土壤湿度1", "土壤湿度2", "土壤湿度3"}; private String spinnervaluse02; TextView time1; private String nsitetype; private MapDataBeanNew curSiteInfo; private double intentLat = 0.0; private double intentLng = 0.0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wheatherinfo); try { intentLat = getIntent().getDoubleExtra("intentLat", 0.0); intentLng = getIntent().getDoubleExtra("intentLng", 0.0); context = this; //getData(); curSiteInfo = (MapDataBeanNew) getIntent().getSerializableExtra(KEY_SITE_INFO); initView(); if(intentLat == 0 || intentLng == 0){ layout_location.setVisibility(View.GONE); }else{ layout_location.setVisibility(View.VISIBLE); } } catch (Exception e){ Log.d("mcg",e.getMessage()); e.printStackTrace(); } } private void getData() { SharedPreferences preferences = getSharedPreferences("wlw_settings", MODE_PRIVATE); String neiip = preferences.getString("neiip", ""); String mark = preferences.getString("netmode", "");//内网访问还是外网访问? nsitetype = AllInfoMap.nsitetype;// } private void initView() { nsitetype = AllInfoMap.nsitetype;// layout_tqyb = (LinearLayout) findViewById(R.id.tab1); layout_nyqx = (LinearLayout) findViewById(R.id.tab2); layout_nyzx = (LinearLayout) findViewById(R.id.tab3); layout_gdnq = (LinearLayout) findViewById(R.id.tab4); layout_tjfx = (LinearLayout) findViewById(R.id.tab5); layout_location = (LinearLayout) findViewById(R.id.tab6); image_ntqx = (ImageView) findViewById(R.id.image_qixiang);//2 image_tqyb = (ImageView) findViewById(R.id.image_yubao);//1 image_nyzx = (ImageView) findViewById(R.id.image_zixun);//3 image_gdnq = (ImageView) findViewById(R.id.image_gdnq);//4 image_tjfx = (ImageView) findViewById(R.id.image_tjfx);//5 layout_tqyb.setOnClickListener(this); layout_nyqx.setOnClickListener(this); layout_nyzx.setOnClickListener(this); layout_gdnq.setOnClickListener(this); layout_tjfx.setOnClickListener(this); layout_location.setOnClickListener(this); mContent = RealTimeFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); } @SuppressLint("NonConstantResourceId") @Override public void onClick(View v) { switch (v.getId()) { case R.id.tab1: layout_tqyb.setBackgroundResource(R.drawable.tabshape_bg); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_nyzx.setImageResource(R.drawable.curve); image_ntqx.setImageResource(R.drawable.history_pic); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic_on); mContent = RealTimeFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab2: layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.drawable.tabshape_bg); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic_on); image_nyzx.setImageResource(R.drawable.curve); mContent = HistoryDataFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab3: showExitGameAlert(); break; case R.id.tab4: layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.drawable.tabshape_bg); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic_on); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve); mContent = CureDataFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab5: jinDuJiaozhang(); break; case R.id.tab6: Intent intent = new Intent(WeatherInfoActivity.this, DeviceMapActivity.class); intent.putExtra("intentLat",intentLat); intent.putExtra("intentLng",intentLng); startActivity(intent); break; case R.id.dateselect1: //弹窗日期选择 new MonPickerDialog(context, dateListener1, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show(); break; } } private DatePickerDialog.OnDateSetListener dateListener1 = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) { calendar.set(Calendar.YEAR, arg1);// 将给定的日历字段设置为给定值。 //calendar.set(Calendar.MONTH, arg2); //calendar.set(Calendar.DAY_OF_MONTH, arg3); SimpleDateFormat df = new SimpleDateFormat("yyyy"); time1.setText(df.format(calendar.getTime())); } }; /** * 时间选择器 */ @SuppressLint("SimpleDateFormat") private void showExitGameAlert() { final AlertDialog dlg = new AlertDialog.Builder(this).create(); dlg.show(); Window window = dlg.getWindow(); // *** 主要就是在这里实现这种效果的. // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容 window.setContentView(R.layout.datepicker_layout); // 为确认按钮添加事件,执行退出应用操作 DatePicker dp = (DatePicker) window.findViewById(R.id.dpPicker); final Calendar calendar = Calendar.getInstance(); // final SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月"); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); // 隐藏日期View ((ViewGroup) ((ViewGroup) dp.getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE); dp.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), (view, year, monthOfYear, dayOfMonth) -> { // 获取一个日历对象,并初始化为当前选中的时间 calendar.set(year, monthOfYear, dayOfMonth); }); RelativeLayout ok = (RelativeLayout) window.findViewById(R.id.YES); ok.setOnClickListener(v -> { layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.drawable.tabshape_bg); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve_hover); String dataTime = format.format(calendar.getTime()); // 携带数据跳转页面 mContent = new MonthDataFragment(); Bundle bundle = new Bundle(); bundle.putString("datatime", dataTime); bundle.putSerializable(KEY_SITE_INFO, curSiteInfo); mContent.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); dlg.cancel(); }); // 关闭alert对话框架 RelativeLayout cancel = (RelativeLayout) window.findViewById(R.id.NO); cancel.setOnClickListener(v -> dlg.cancel()); } /** * 重写datePicker 1.只显示 年-月 2.title 只显示 年-月 * * @author lmw */ public class MonPickerDialog extends DatePickerDialog { public MonPickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) { super(context, callBack, year, monthOfYear, dayOfMonth); //this.setTitle(year + "年" + (monthOfYear + 1) + "月"); this.setTitle(year + "年"); ((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE); ((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(1).setVisibility(View.GONE); } @Override public void onDateChanged(DatePicker view, int year, int month, int day) { super.onDateChanged(view, year, month, day); //this.setTitle(year + "年" + (month + 1) + "月"); this.setTitle(year + "年"); } } private void jinDuJiaozhang() { final Dialog myDialog = new Dialog(context); //dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myDialog.show(); // 设置宽度为屏幕的宽度 WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes(); lp.width = (int) (display.getWidth()); // 设置宽度 myDialog.getWindow().setAttributes(lp); //myDialog.setCancelable(false);//调用这个方法时,按对话框以外的地方不起作用。按返回键也不起作用 myDialog.setCanceledOnTouchOutside(false);//调用这个方法时,按对话框以外的地方不起作用。按返回键还起作用 Window window = myDialog.getWindow(); window.setContentView(R.layout.dialog_et22);// setContentView()必须放在show()的后面,不然会报错 Spinner sp_01 = (Spinner) window.findViewById(R.id.sp_01); // 将可选内容与ArrayAdapter连接起来 if (nsitetype.equals("01") || !Utils.isOldDevice(curSiteInfo.getId())) { // 十五项因子 spinneradapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, m2); } else if (nsitetype.equals("02")) { // 八项因子 spinneradapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, m1); } // 设置下拉列表的风格 spinneradapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // 将adapter 添加到spinner中 sp_01.setAdapter(spinneradapter); sp_01.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub /*if (position == 0) { spinnervaluse02 = "卵"; } else if (position == 1) { spinnervaluse02 = "幼虫"; } else if (position == 2) { spinnervaluse02 = "蛹"; } else if (position == 3) { spinnervaluse02 = "成虫"; }*/ if (nsitetype.equals("01") || !Utils.isOldDevice(curSiteInfo.getId())) { // 十五项因子 spinnervaluse02 = m2[position]; } else if (nsitetype.equals("02")) { // 八项因子 spinnervaluse02 = m1[position]; } } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); time1 = (TextView) window.findViewById(R.id.time1); LinearLayout dateselect1 = (LinearLayout) window.findViewById(R.id.dateselect1); // 初始化当前时间 updateDate(); dateselect1.setOnClickListener(this); Button btn_ensure = (Button) window.findViewById(R.id.btn_ensure); Button btn_cancel = (Button) window.findViewById(R.id.btn_cancel); btn_ensure.setOnClickListener(v -> { //spinnervaluse02 time1 //统计分析 layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.drawable.tabshape_bg); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_01); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve); mContent =new TjfxDataFragment(); Bundle bundle = new Bundle(); bundle.putString("spinnervaluse", spinnervaluse02); bundle.putString("time1", time1.getText().toString()); bundle.putSerializable(KEY_SITE_INFO,curSiteInfo); mContent.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); myDialog.dismiss(); }); btn_cancel.setOnClickListener(v -> { // TODO Auto-generated method stub myDialog.dismiss(); }); } private void updateDate() {//时间控件 SimpleDateFormat df = new SimpleDateFormat("yyyy"); time1.setText(df.format(calendar.getTime())); } } WeatherInfoActivity代码的datepicker_layout.xml:<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/white" android:orientation="vertical" > <DatePicker android:id="@+id/dpPicker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:calendarViewShown="false" /> <View android:layout_width="wrap_content" android:layout_height="1dp" android:layout_below="@id/dpPicker" android:background="#e1e5e7" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/dpPicker" android:layout_centerHorizontal="true" android:layout_marginTop="1dp" android:gravity="center" android:orientation="horizontal" > <RelativeLayout android:id="@+id/YES" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="确定" android:layout_margin="10dp" android:textColor="@android:color/black" android:textSize="22sp" /> </RelativeLayout> <View android:layout_width="1dp" android:layout_height="match_parent" android:background="#e1e5e7" /> <RelativeLayout android:id="@+id/NO" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_margin="10dp" android:text="取消" android:textColor="@android:color/black" android:textSize="22sp" /> </RelativeLayout> </LinearLayout> </RelativeLayout> 依据上述代码解释为什么datepicker_layout.xml代码一样,但是在WeatherInfoActivity和FanHui使用中显示布局不一样。
06-26
package com.example.music_player.fragment; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.example.music_player.Item; import com.example.music_player.ItemAdapter; import com.example.music_player.R; import java.util.ArrayList; import java.util.List; /** * A simple {@link Fragment} subclass. * Use the {@link SearchFragment#newInstance} factory method to * create an instance of this fragment. */ public class SearchFragment extends Fragment { private RecyclerView recyclerView; private ItemAdapter adapter; private List<Item> filteredItems = new ArrayList<>(); private String currentCategory = "meditation"; // 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 SearchFragment() { // 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 SearchFragment. */ // TODO: Rename and change types and number of parameters public static SearchFragment newInstance(String param1, String param2) { SearchFragment fragment = new SearchFragment(); 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 View view = inflater.inflate(R.layout.fragment_search, container, false); // recyclerView = view.findViewById(R.id.recycler_items); // initDummyData(); // //initViews(view); // // // 检查是否为null // if (recyclerView != null) { // initViews(view); // 将初始化逻辑移到这里 // } else { // Log.e(TAG, "RecyclerView is null! Check your layout file."); // } return view; } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // 1. 初始化RecyclerView recyclerView = view.findViewById(R.id.recycler_items); if (recyclerView == null) { Log.e("SearchFragment", "RecyclerView is null! Check layout file."); return; } // 2. 创建布局管理器 recyclerView.setLayoutManager(new LinearLayoutManager(requireContext())); // 3. 创建模拟数据 initDummyData(); // 4. 初始化适配器并设置 adapter = new ItemAdapter(requireContext(), filteredItems); recyclerView.setAdapter(adapter); // 5. 可选:添加分割线 // recyclerView.addItemDecoration(new DividerItemDecoration( // getContext(), DividerItemDecoration.VERTICAL)); // 设置分类标签点击事件 setupCategoryTabs(view); } private void initDummyData() { filteredItems.clear(); filteredItems.add(new Item(R.drawable.pic1, "水滴", 256, "冥想")); filteredItems.add(new Item(R.drawable.pic1, "水滴", 256, "冥想")); filteredItems.add(new Item(R.drawable.pic1, "水滴", 256, "冥想")); filteredItems.add(new Item(R.drawable.pic1, "水滴", 256, "冥想")); } // // private void initViews(View view) { // // 初始化RecyclerView // //recyclerView = view.findViewById(R.id.recycler_items); // recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // adapter = new ItemAdapter(new ArrayList<>(filteredItems)); // recyclerView.setAdapter(adapter); // // // 设置类别点击监听 // setupCategoryClicks(view); // } // private void setupCategoryClicks(View rootView) { // int[] categoryIds = { // R.id.category_meditation, // R.id.category_white_noise // }; // // for (int id : categoryIds) { // TextView categoryView = rootView.findViewById(id); // categoryView.setOnClickListener(v -> { // // 更新选中状态 // updateCategorySelection(v); // // // 根据tag获取类别 // String category = v.getTag().toString(); // filterItems(category); // }); // } // } private void setupCategoryTabs(View view) { TextView meditation = view.findViewById(R.id.category_meditation); TextView whiteNoise = view.findViewById(R.id.category_white_noise); // 设置初始选中状态 meditation.setSelected(true); meditation.setOnClickListener(v -> { meditation.setSelected(true); whiteNoise.setSelected(false); filterItems("冥想"); }); whiteNoise.setOnClickListener(v -> { meditation.setSelected(false); whiteNoise.setSelected(true); filterItems("白噪音"); }); } // private void updateCategorySelection(View selectedView) { // // 重置所有类别状态 // ViewGroup container = (ViewGroup) selectedView.getParent(); // for (int i = 0; i < container.getChildCount(); i++) { // View child = container.getChildAt(i); // child.setSelected(child == selectedView); // } // } private void filterItems(String category) { List<Item> filtered = new ArrayList<>(); for (Item item : filteredItems) { if (category.equals(item.getCategory())) { // filteredItems.add(item); // } } adapter = new ItemAdapter(getContext(), filtered); recyclerView.setAdapter(adapter); } // private void filterItems(String category) { // filteredItems.clear(); // for (Item item : filteredItems) { // if (category.equals(item.getCategory())) { // filteredItems.add(item); // } // } // adapter.updateList(filteredItems); // } } }
06-25
datepicker_layout.xml代码完全一样,把FanHui.java布局方式修改完全复制成WeatherInfoActivity.java完全一样的。WeatherInfoActivity.java:package com.jd.projects.wlw.weatherinfo; import static com.jd.projects.wlw.weatherinfo.AllInfoMap.KEY_SITE_INFO; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.DatePickerDialog; import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.view.Display; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.DatePicker; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Spinner; import android.widget.TextView; import android.widget.TimePicker; import com.jd.projects.wlw.DeviceMapActivity; import com.jd.projects.wlw.R; import com.jd.projects.wlw.bean.MapDataBean; import com.jd.projects.wlw.bean.new_webservice.MapDataBeanNew; import com.jd.projects.wlw.fragment.CureDataFragment; import com.jd.projects.wlw.fragment.HistoryDataFragment; import com.jd.projects.wlw.fragment.MonthDataFragment; import com.jd.projects.wlw.fragment.RealTimeFragment; import com.jd.projects.wlw.fragment.TjfxDataFragment; import com.jd.projects.wlw.update.Utils; import java.text.SimpleDateFormat; import java.util.Calendar; public class WeatherInfoActivity extends FragmentActivity implements OnClickListener { private LinearLayout layout_tqyb, layout_nyqx, layout_nyzx, layout_gdnq, layout_tjfx,layout_location; private ImageView image_ntqx, image_tqyb, image_nyzx, image_gdnq, image_tjfx; private Fragment mContent; public static MapDataBean realdata; // public static String asitename; private Calendar calendar = Calendar.getInstance(); private Context context; private ArrayAdapter<String> spinneradapter; private static final String[] m2 = {"空气温度", "空气湿度", "土壤温度1", "土壤温度2", "土壤温度3", "土壤湿度", "光照度", "蒸发量", "降雨量", "风速", "风向", "结露", "气压", "总辐射", "光合有效辐射"}; private static final String[] m1 = {"空气温度", "空气湿度", "土壤温度1", "土壤温度2", "土壤温度3", "土壤湿度1", "土壤湿度2", "土壤湿度3"}; private String spinnervaluse02; TextView time1; private String nsitetype; private MapDataBeanNew curSiteInfo; private double intentLat = 0.0; private double intentLng = 0.0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wheatherinfo); try { intentLat = getIntent().getDoubleExtra("intentLat", 0.0); intentLng = getIntent().getDoubleExtra("intentLng", 0.0); context = this; //getData(); curSiteInfo = (MapDataBeanNew) getIntent().getSerializableExtra(KEY_SITE_INFO); initView(); if(intentLat == 0 || intentLng == 0){ layout_location.setVisibility(View.GONE); }else{ layout_location.setVisibility(View.VISIBLE); } } catch (Exception e){ Log.d("mcg",e.getMessage()); e.printStackTrace(); } } private void getData() { SharedPreferences preferences = getSharedPreferences("wlw_settings", MODE_PRIVATE); String neiip = preferences.getString("neiip", ""); String mark = preferences.getString("netmode", "");//内网访问还是外网访问? nsitetype = AllInfoMap.nsitetype;// } private void initView() { nsitetype = AllInfoMap.nsitetype;// layout_tqyb = (LinearLayout) findViewById(R.id.tab1); layout_nyqx = (LinearLayout) findViewById(R.id.tab2); layout_nyzx = (LinearLayout) findViewById(R.id.tab3); layout_gdnq = (LinearLayout) findViewById(R.id.tab4); layout_tjfx = (LinearLayout) findViewById(R.id.tab5); layout_location = (LinearLayout) findViewById(R.id.tab6); image_ntqx = (ImageView) findViewById(R.id.image_qixiang);//2 image_tqyb = (ImageView) findViewById(R.id.image_yubao);//1 image_nyzx = (ImageView) findViewById(R.id.image_zixun);//3 image_gdnq = (ImageView) findViewById(R.id.image_gdnq);//4 image_tjfx = (ImageView) findViewById(R.id.image_tjfx);//5 layout_tqyb.setOnClickListener(this); layout_nyqx.setOnClickListener(this); layout_nyzx.setOnClickListener(this); layout_gdnq.setOnClickListener(this); layout_tjfx.setOnClickListener(this); layout_location.setOnClickListener(this); mContent = RealTimeFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); } @SuppressLint("NonConstantResourceId") @Override public void onClick(View v) { switch (v.getId()) { case R.id.tab1: layout_tqyb.setBackgroundResource(R.drawable.tabshape_bg); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_nyzx.setImageResource(R.drawable.curve); image_ntqx.setImageResource(R.drawable.history_pic); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic_on); mContent = RealTimeFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab2: layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.drawable.tabshape_bg); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic_on); image_nyzx.setImageResource(R.drawable.curve); mContent = HistoryDataFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab3: showExitGameAlert(); break; case R.id.tab4: layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.drawable.tabshape_bg); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic_on); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve); mContent = CureDataFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab5: jinDuJiaozhang(); break; case R.id.tab6: Intent intent = new Intent(WeatherInfoActivity.this, DeviceMapActivity.class); intent.putExtra("intentLat",intentLat); intent.putExtra("intentLng",intentLng); startActivity(intent); break; case R.id.dateselect1: //弹窗日期选择 new MonPickerDialog(context, dateListener1, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show(); break; } } private DatePickerDialog.OnDateSetListener dateListener1 = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) { calendar.set(Calendar.YEAR, arg1);// 将给定的日历字段设置为给定值。 //calendar.set(Calendar.MONTH, arg2); //calendar.set(Calendar.DAY_OF_MONTH, arg3); SimpleDateFormat df = new SimpleDateFormat("yyyy"); time1.setText(df.format(calendar.getTime())); } }; /** * 时间选择器 */ @SuppressLint("SimpleDateFormat") private void showExitGameAlert() { final AlertDialog dlg = new AlertDialog.Builder(this).create(); dlg.show(); Window window = dlg.getWindow(); // *** 主要就是在这里实现这种效果的. // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容 window.setContentView(R.layout.datepicker_layout); // 为确认按钮添加事件,执行退出应用操作 DatePicker dp = (DatePicker) window.findViewById(R.id.dpPicker); final Calendar calendar = Calendar.getInstance(); // final SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月"); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); // 隐藏日期View ((ViewGroup) ((ViewGroup) dp.getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE); dp.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), (view, year, monthOfYear, dayOfMonth) -> { // 获取一个日历对象,并初始化为当前选中的时间 calendar.set(year, monthOfYear, dayOfMonth); }); RelativeLayout ok = (RelativeLayout) window.findViewById(R.id.YES); ok.setOnClickListener(v -> { layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.drawable.tabshape_bg); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve_hover); String dataTime = format.format(calendar.getTime()); // 携带数据跳转页面 mContent = new MonthDataFragment(); Bundle bundle = new Bundle(); bundle.putString("datatime", dataTime); bundle.putSerializable(KEY_SITE_INFO, curSiteInfo); mContent.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); dlg.cancel(); }); // 关闭alert对话框架 RelativeLayout cancel = (RelativeLayout) window.findViewById(R.id.NO); cancel.setOnClickListener(v -> dlg.cancel()); } /** * 重写datePicker 1.只显示 年-月 2.title 只显示 年-月 * * @author lmw */ public class MonPickerDialog extends DatePickerDialog { public MonPickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) { super(context, callBack, year, monthOfYear, dayOfMonth); //this.setTitle(year + "年" + (monthOfYear + 1) + "月"); this.setTitle(year + "年"); ((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE); ((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(1).setVisibility(View.GONE); } @Override public void onDateChanged(DatePicker view, int year, int month, int day) { super.onDateChanged(view, year, month, day); //this.setTitle(year + "年" + (month + 1) + "月"); this.setTitle(year + "年"); } } private void jinDuJiaozhang() { final Dialog myDialog = new Dialog(context); //dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myDialog.show(); // 设置宽度为屏幕的宽度 WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes(); lp.width = (int) (display.getWidth()); // 设置宽度 myDialog.getWindow().setAttributes(lp); //myDialog.setCancelable(false);//调用这个方法时,按对话框以外的地方不起作用。按返回键也不起作用 myDialog.setCanceledOnTouchOutside(false);//调用这个方法时,按对话框以外的地方不起作用。按返回键还起作用 Window window = myDialog.getWindow(); window.setContentView(R.layout.dialog_et22);// setContentView()必须放在show()的后面,不然会报错 Spinner sp_01 = (Spinner) window.findViewById(R.id.sp_01); // 将可选内容与ArrayAdapter连接起来 if (nsitetype.equals("01") || !Utils.isOldDevice(curSiteInfo.getId())) { // 十五项因子 spinneradapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, m2); } else if (nsitetype.equals("02")) { // 八项因子 spinneradapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, m1); } // 设置下拉列表的风格 spinneradapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // 将adapter 添加到spinner中 sp_01.setAdapter(spinneradapter); sp_01.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub /*if (position == 0) { spinnervaluse02 = "卵"; } else if (position == 1) { spinnervaluse02 = "幼虫"; } else if (position == 2) { spinnervaluse02 = "蛹"; } else if (position == 3) { spinnervaluse02 = "成虫"; }*/ if (nsitetype.equals("01") || !Utils.isOldDevice(curSiteInfo.getId())) { // 十五项因子 spinnervaluse02 = m2[position]; } else if (nsitetype.equals("02")) { // 八项因子 spinnervaluse02 = m1[position]; } } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); time1 = (TextView) window.findViewById(R.id.time1); LinearLayout dateselect1 = (LinearLayout) window.findViewById(R.id.dateselect1); // 初始化当前时间 updateDate(); dateselect1.setOnClickListener(this); Button btn_ensure = (Button) window.findViewById(R.id.btn_ensure); Button btn_cancel = (Button) window.findViewById(R.id.btn_cancel); btn_ensure.setOnClickListener(v -> { //spinnervaluse02 time1 //统计分析 layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.drawable.tabshape_bg); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_01); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve); mContent =new TjfxDataFragment(); Bundle bundle = new Bundle(); bundle.putString("spinnervaluse", spinnervaluse02); bundle.putString("time1", time1.getText().toString()); bundle.putSerializable(KEY_SITE_INFO,curSiteInfo); mContent.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); myDialog.dismiss(); }); btn_cancel.setOnClickListener(v -> { // TODO Auto-generated method stub myDialog.dismiss(); }); } private void updateDate() {//时间控件 SimpleDateFormat df = new SimpleDateFormat("yyyy"); time1.setText(df.format(calendar.getTime())); } } FanHui.java:package com.videogo.ui.login; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.TextView; import com.videogo.openapi.EZOpenSDK; import ezviz.ezopensdk.R; import androidx.appcompat.app.AppCompatActivity; import java.util.Calendar; import java.util.Locale; import com.videogo.widget.TitleBar; import android.app.DatePickerDialog; public class FanHui extends AppCompatActivity { private static final String TAG = "EZPreview"; private String mAppKey; private String mDeviceSerial; private String mVerifyCode; private String mAccessToken; private int mCameraNo; private TextView mDateTextView; private int mSelectedYear, mSelectedMonth, mSelectedDay; private static final String KEY_APPKEY = "appkey"; private static final String KEY_SERIAL = "serial"; private static final String KEY_VERIFYCODE = "VerifyCode"; private static final String KEY_ACCESSTOKEN = "accessToken"; private static final String KEY_CAMERANO = "cameraNo"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ez_playback_list_page); extractParametersFromIntent(); final Calendar calendar = Calendar.getInstance(); mSelectedYear = calendar.get(Calendar.YEAR); mSelectedMonth = calendar.get(Calendar.MONTH); mSelectedDay = calendar.get(Calendar.DAY_OF_MONTH); // 设置日期显示模块 setupDatePicker(); View fanHui = findViewById(R.id.fanhui); fanHui.setOnClickListener(v -> finish()); Button huifangBtn = findViewById(R.id.fanhui); huifangBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 创建Intent跳转到FanHui活动 Intent intent = new Intent(FanHui.this, MainActivity.class); // 传递必要参数(可选) intent.putExtra("deviceSerial", mDeviceSerial); intent.putExtra("cameraNo", mCameraNo); intent.putExtra("accessToken", mAccessToken); intent.putExtra("appkey", mAppKey); intent.putExtra("verifyCode", mVerifyCode); startActivity(intent); } }); } private void setupDatePicker() { mDateTextView = findViewById(R.id.date_text); ImageButton datePickerButton = findViewById(R.id.date_picker_button); updateDateDisplay(); datePickerButton.setOnClickListener(v -> showDatePickerDialog()); } private void updateDateDisplay() { String formattedDate = String.format(Locale.getDefault(), "%d年%02d月%02d日", mSelectedYear, mSelectedMonth + 1, // 月份需要+1 mSelectedDay); mDateTextView.setText(formattedDate); } private void showDatePickerDialog() { DatePickerDialog datePickerDialog = new DatePickerDialog( this, (view, year, month, dayOfMonth) -> { // 更新日期 }, mSelectedYear, mSelectedMonth, mSelectedDay ); datePickerDialog.show(); } private void extractParametersFromIntent() { Bundle extras = getIntent().getExtras(); if (extras != null) { mAppKey = extras.getString(KEY_APPKEY, ""); mDeviceSerial = extras.getString(KEY_SERIAL, ""); mVerifyCode = extras.getString(KEY_VERIFYCODE, ""); mAccessToken = extras.getString(KEY_ACCESSTOKEN, ""); mCameraNo = extras.getInt(KEY_CAMERANO, 0); Log.d(TAG, "Received parameters:"); Log.d(TAG, "AppKey: " + mAppKey); Log.d(TAG, "DeviceSerial: " + mDeviceSerial); Log.d(TAG, "VerifyCode: " + mVerifyCode); Log.d(TAG, "AccessToken: " + mAccessToken); Log.d(TAG, "CameraNo: " + mCameraNo); } else { Log.e(TAG, "No parameters received from intent"); // 如果没有参数,可以显示错误信息并退出 // finish(); } } }
06-26
/****************************************************** * 修改电阻Layout CDF参数(带单位转换功能) * 适用Cadence Virtuoso IC6.x Layout视图 ******************************************************/ procedure( ModifyResistorLayoutCDF() let( (lib cell view cdfId param) ;;; 目标元件信息 lib = "myLib" cell = "resistor" view = "layout" ;;; 获取Layout视图CDF cdfId = cdfGetBaseCellCDF(lib cell view) when( cdfId ;;; 创建/更新Layout参数组 cdfCreateParamGroup( cdfId "Layout_Params" ?prompt "Physical Parameters" ?rank 1 ) ;;; 1. 修改宽度参数(带μm单位) if( param = cdfFindParamByName(cdfId "width") then cdfChangeParamDefValue(param "2u") ; 默认值带单位 cdfSetUnitScaleFactor(cdfId "width" 1e-6) ; μm→m转换 cdfSetUnitLabel(cdfId "width" "μm") else cdfCreateParam( cdfId ?name "width" ?prompt "Width" ?defValue "2u" ?type "float" ?parseAsCEL t ?group "Layout_Params" ) ) ;;; 2. 添加间距参数(工艺相关) unless( cdfFindParamByName(cdfId "spacing") cdfCreateParam( cdfId ?name "spacing" ?prompt "Metal Spacing" ?defValue "0.5u" ?type "float" ?parseAsCEL t ?group "Layout_Params" ) cdfSetUnitScaleFactor(cdfId "spacing" 1e-6) cdfSetUnitLabel(cdfId "spacing" "μm") ) ;;; 3. 更新电阻值参数(带单位转换) when( param = cdfFindParamByName(cdfId "r") cdfSetUnitScaleFactor(cdfId "r" 1e3) ; kΩ→Ω cdfSetUnitLabel(cdfId "r" "kΩ") cdfChangeParamDefValue(param "1k") ; 更新默认值 cdfAddParamCallback(param 'checkResValue) ) ;;; 保存修改 cdfSaveCDF(cdfId) printf("CDF parameters updated for %s/%s/%s\n" lib cell view) ) ) ) ;;; 参数校验回调函数 procedure( checkResValue(paramName) let((val minVal maxVal) val = cdfFindParamByName(cdfgData symbolCDF paramName)->value minVal = 100 ; 100Ω = 0.1kΩ maxVal = 1e6 ; 1MΩ = 1000kΩ unless( val >= minVal && val <= maxVal error("Resistance value must between %dk and %dM!" minVal/1e3 maxVal/1e6) ) ) ) 将这个代码删除添加间距参数与更新电阻值参数语句,添加修改长度参数,最后将中文注释改为应为
03-08
现在是在datepicker_layout.xml代码完全一致的前提下,在代码WeatherInfoActivity和FanHui代码中使用的datepicker_layout时间选择器显示的布局样式还是完全不一样,给我直接一次性解决布局样式完全不一样的问题。WeatherInfoActivity:package com.jd.projects.wlw.weatherinfo; import static com.jd.projects.wlw.weatherinfo.AllInfoMap.KEY_SITE_INFO; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.DatePickerDialog; import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.view.Display; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.DatePicker; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.Spinner; import android.widget.TextView; import android.widget.TimePicker; import com.jd.projects.wlw.DeviceMapActivity; import com.jd.projects.wlw.R; import com.jd.projects.wlw.bean.MapDataBean; import com.jd.projects.wlw.bean.new_webservice.MapDataBeanNew; import com.jd.projects.wlw.fragment.CureDataFragment; import com.jd.projects.wlw.fragment.HistoryDataFragment; import com.jd.projects.wlw.fragment.MonthDataFragment; import com.jd.projects.wlw.fragment.RealTimeFragment; import com.jd.projects.wlw.fragment.TjfxDataFragment; import com.jd.projects.wlw.update.Utils; import java.text.SimpleDateFormat; import java.util.Calendar; public class WeatherInfoActivity extends FragmentActivity implements OnClickListener { private LinearLayout layout_tqyb, layout_nyqx, layout_nyzx, layout_gdnq, layout_tjfx,layout_location; private ImageView image_ntqx, image_tqyb, image_nyzx, image_gdnq, image_tjfx; private Fragment mContent; public static MapDataBean realdata; // public static String asitename; private Calendar calendar = Calendar.getInstance(); private Context context; private ArrayAdapter<String> spinneradapter; private static final String[] m2 = {"空气温度", "空气湿度", "土壤温度1", "土壤温度2", "土壤温度3", "土壤湿度", "光照度", "蒸发量", "降雨量", "风速", "风向", "结露", "气压", "总辐射", "光合有效辐射"}; private static final String[] m1 = {"空气温度", "空气湿度", "土壤温度1", "土壤温度2", "土壤温度3", "土壤湿度1", "土壤湿度2", "土壤湿度3"}; private String spinnervaluse02; TextView time1; private String nsitetype; private MapDataBeanNew curSiteInfo; private double intentLat = 0.0; private double intentLng = 0.0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wheatherinfo); try { intentLat = getIntent().getDoubleExtra("intentLat", 0.0); intentLng = getIntent().getDoubleExtra("intentLng", 0.0); context = this; //getData(); curSiteInfo = (MapDataBeanNew) getIntent().getSerializableExtra(KEY_SITE_INFO); initView(); if(intentLat == 0 || intentLng == 0){ layout_location.setVisibility(View.GONE); }else{ layout_location.setVisibility(View.VISIBLE); } } catch (Exception e){ Log.d("mcg",e.getMessage()); e.printStackTrace(); } } private void getData() { SharedPreferences preferences = getSharedPreferences("wlw_settings", MODE_PRIVATE); String neiip = preferences.getString("neiip", ""); String mark = preferences.getString("netmode", "");//内网访问还是外网访问? nsitetype = AllInfoMap.nsitetype;// } private void initView() { nsitetype = AllInfoMap.nsitetype;// layout_tqyb = (LinearLayout) findViewById(R.id.tab1); layout_nyqx = (LinearLayout) findViewById(R.id.tab2); layout_nyzx = (LinearLayout) findViewById(R.id.tab3); layout_gdnq = (LinearLayout) findViewById(R.id.tab4); layout_tjfx = (LinearLayout) findViewById(R.id.tab5); layout_location = (LinearLayout) findViewById(R.id.tab6); image_ntqx = (ImageView) findViewById(R.id.image_qixiang);//2 image_tqyb = (ImageView) findViewById(R.id.image_yubao);//1 image_nyzx = (ImageView) findViewById(R.id.image_zixun);//3 image_gdnq = (ImageView) findViewById(R.id.image_gdnq);//4 image_tjfx = (ImageView) findViewById(R.id.image_tjfx);//5 layout_tqyb.setOnClickListener(this); layout_nyqx.setOnClickListener(this); layout_nyzx.setOnClickListener(this); layout_gdnq.setOnClickListener(this); layout_tjfx.setOnClickListener(this); layout_location.setOnClickListener(this); mContent = RealTimeFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); } @SuppressLint("NonConstantResourceId") @Override public void onClick(View v) { switch (v.getId()) { case R.id.tab1: layout_tqyb.setBackgroundResource(R.drawable.tabshape_bg); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_nyzx.setImageResource(R.drawable.curve); image_ntqx.setImageResource(R.drawable.history_pic); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic_on); mContent = RealTimeFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab2: layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.drawable.tabshape_bg); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic_on); image_nyzx.setImageResource(R.drawable.curve); mContent = HistoryDataFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab3: showExitGameAlert(); break; case R.id.tab4: layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.drawable.tabshape_bg); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic_on); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve); mContent = CureDataFragment.newInstance(curSiteInfo); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); break; case R.id.tab5: jinDuJiaozhang(); break; case R.id.tab6: Intent intent = new Intent(WeatherInfoActivity.this, DeviceMapActivity.class); intent.putExtra("intentLat",intentLat); intent.putExtra("intentLng",intentLng); startActivity(intent); break; case R.id.dateselect1: //弹窗日期选择 new MonPickerDialog(context, dateListener1, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show(); break; } } private DatePickerDialog.OnDateSetListener dateListener1 = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) { calendar.set(Calendar.YEAR, arg1);// 将给定的日历字段设置为给定值。 //calendar.set(Calendar.MONTH, arg2); //calendar.set(Calendar.DAY_OF_MONTH, arg3); SimpleDateFormat df = new SimpleDateFormat("yyyy"); time1.setText(df.format(calendar.getTime())); } }; /** * 时间选择器 */ @SuppressLint("SimpleDateFormat") private void showExitGameAlert() { final AlertDialog dlg = new AlertDialog.Builder(this).create(); dlg.show(); Window window = dlg.getWindow(); // *** 主要就是在这里实现这种效果的. // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容 window.setContentView(R.layout.datepicker_layout); // 为确认按钮添加事件,执行退出应用操作 DatePicker dp = (DatePicker) window.findViewById(R.id.dpPicker); final Calendar calendar = Calendar.getInstance(); // final SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月"); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); // 隐藏日期View ((ViewGroup) ((ViewGroup) dp.getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE); dp.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), (view, year, monthOfYear, dayOfMonth) -> { // 获取一个日历对象,并初始化为当前选中的时间 calendar.set(year, monthOfYear, dayOfMonth); }); RelativeLayout ok = (RelativeLayout) window.findViewById(R.id.YES); ok.setOnClickListener(v -> { layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.drawable.tabshape_bg); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.color.transparent); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_02); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve_hover); String dataTime = format.format(calendar.getTime()); // 携带数据跳转页面 mContent = new MonthDataFragment(); Bundle bundle = new Bundle(); bundle.putString("datatime", dataTime); bundle.putSerializable(KEY_SITE_INFO, curSiteInfo); mContent.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); dlg.cancel(); }); // 关闭alert对话框架 RelativeLayout cancel = (RelativeLayout) window.findViewById(R.id.NO); cancel.setOnClickListener(v -> dlg.cancel()); } /** * 重写datePicker 1.只显示 年-月 2.title 只显示 年-月 * * @author lmw */ public class MonPickerDialog extends DatePickerDialog { public MonPickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) { super(context, callBack, year, monthOfYear, dayOfMonth); //this.setTitle(year + "年" + (monthOfYear + 1) + "月"); this.setTitle(year + "年"); ((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE); ((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(1).setVisibility(View.GONE); } @Override public void onDateChanged(DatePicker view, int year, int month, int day) { super.onDateChanged(view, year, month, day); //this.setTitle(year + "年" + (month + 1) + "月"); this.setTitle(year + "年"); } } private void jinDuJiaozhang() { final Dialog myDialog = new Dialog(context); //dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myDialog.show(); // 设置宽度为屏幕的宽度 WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes(); lp.width = (int) (display.getWidth()); // 设置宽度 myDialog.getWindow().setAttributes(lp); //myDialog.setCancelable(false);//调用这个方法时,按对话框以外的地方不起作用。按返回键也不起作用 myDialog.setCanceledOnTouchOutside(false);//调用这个方法时,按对话框以外的地方不起作用。按返回键还起作用 Window window = myDialog.getWindow(); window.setContentView(R.layout.dialog_et22);// setContentView()必须放在show()的后面,不然会报错 Spinner sp_01 = (Spinner) window.findViewById(R.id.sp_01); // 将可选内容与ArrayAdapter连接起来 if (nsitetype.equals("01") || !Utils.isOldDevice(curSiteInfo.getId())) { // 十五项因子 spinneradapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, m2); } else if (nsitetype.equals("02")) { // 八项因子 spinneradapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, m1); } // 设置下拉列表的风格 spinneradapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // 将adapter 添加到spinner中 sp_01.setAdapter(spinneradapter); sp_01.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub /*if (position == 0) { spinnervaluse02 = "卵"; } else if (position == 1) { spinnervaluse02 = "幼虫"; } else if (position == 2) { spinnervaluse02 = "蛹"; } else if (position == 3) { spinnervaluse02 = "成虫"; }*/ if (nsitetype.equals("01") || !Utils.isOldDevice(curSiteInfo.getId())) { // 十五项因子 spinnervaluse02 = m2[position]; } else if (nsitetype.equals("02")) { // 八项因子 spinnervaluse02 = m1[position]; } } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); time1 = (TextView) window.findViewById(R.id.time1); LinearLayout dateselect1 = (LinearLayout) window.findViewById(R.id.dateselect1); // 初始化当前时间 updateDate(); dateselect1.setOnClickListener(this); Button btn_ensure = (Button) window.findViewById(R.id.btn_ensure); Button btn_cancel = (Button) window.findViewById(R.id.btn_cancel); btn_ensure.setOnClickListener(v -> { //spinnervaluse02 time1 //统计分析 layout_tqyb.setBackgroundResource(R.color.transparent); layout_nyqx.setBackgroundResource(R.color.transparent); layout_nyzx.setBackgroundResource(R.color.transparent); layout_gdnq.setBackgroundResource(R.color.transparent); layout_tjfx.setBackgroundResource(R.drawable.tabshape_bg); image_tjfx.setImageResource(R.drawable.sh_wxry_rwcx_01); image_gdnq.setImageResource(R.drawable.disease_pic); image_tqyb.setImageResource(R.drawable.real_pic); image_ntqx.setImageResource(R.drawable.history_pic); image_nyzx.setImageResource(R.drawable.curve); mContent =new TjfxDataFragment(); Bundle bundle = new Bundle(); bundle.putString("spinnervaluse", spinnervaluse02); bundle.putString("time1", time1.getText().toString()); bundle.putSerializable(KEY_SITE_INFO,curSiteInfo); mContent.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); myDialog.dismiss(); }); btn_cancel.setOnClickListener(v -> { // TODO Auto-generated method stub myDialog.dismiss(); }); } private void updateDate() {//时间控件 SimpleDateFormat df = new SimpleDateFormat("yyyy"); time1.setText(df.format(calendar.getTime())); } } FanHui:package com.videogo.ui.login; import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.DatePicker; import android.widget.ImageButton; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; import com.videogo.openapi.EZOpenSDK; import com.videogo.widget.TitleBar; import ezviz.ezopensdk.R; import java.util.Calendar; import java.util.Locale; public class FanHui extends AppCompatActivity { private static final String TAG = "EZPreview"; private String mAppKey; private String mDeviceSerial; private String mVerifyCode; private String mAccessToken; private int mCameraNo; private TextView mDateTextView; private int mSelectedYear, mSelectedMonth, mSelectedDay; private static final String KEY_APPKEY = "appkey"; private static final String KEY_SERIAL = "serial"; private static final String KEY_VERIFYCODE = "VerifyCode"; private static final String KEY_ACCESSTOKEN = "accessToken"; private static final String KEY_CAMERANO = "cameraNo"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ez_playback_list_page); extractParametersFromIntent(); final Calendar calendar = Calendar.getInstance(); mSelectedYear = calendar.get(Calendar.YEAR); mSelectedMonth = calendar.get(Calendar.MONTH); mSelectedDay = calendar.get(Calendar.DAY_OF_MONTH); // 设置日期显示模块 setupDatePicker(); View fanHui = findViewById(R.id.fanhui); fanHui.setOnClickListener(v -> finish()); Button huifangBtn = findViewById(R.id.fanhui); huifangBtn.setOnClickListener(v -> { Intent intent = new Intent(FanHui.this, MainActivity.class); intent.putExtra("deviceSerial", mDeviceSerial); intent.putExtra("cameraNo", mCameraNo); intent.putExtra("accessToken", mAccessToken); intent.putExtra("appkey", mAppKey); intent.putExtra("verifyCode", mVerifyCode); startActivity(intent); }); } private void setupDatePicker() { mDateTextView = findViewById(R.id.date_text); ImageButton datePickerButton = findViewById(R.id.date_picker_button); updateDateDisplay(); datePickerButton.setOnClickListener(v -> showDatePickerDialog()); } private void updateDateDisplay() { String formattedDate = String.format(Locale.getDefault(), "%d年%02d月%02d日", mSelectedYear, mSelectedMonth + 1, // 月份需要+1 mSelectedDay); mDateTextView.setText(formattedDate); } private void showDatePickerDialog() { final AlertDialog dlg = new AlertDialog.Builder(this).create(); dlg.show(); Window window = dlg.getWindow(); window.setContentView(R.layout.datepicker_layout); // 设置对话框宽度 WindowManager.LayoutParams lp = window.getAttributes(); lp.width = WindowManager.LayoutParams.MATCH_PARENT; // 匹配父容器宽度 window.setAttributes(lp); // 初始化日期选择器 DatePicker dpPicker = window.findViewById(R.id.dpPicker); dpPicker.init(mSelectedYear, mSelectedMonth, mSelectedDay, null); // 获取按钮 RelativeLayout yesButton = window.findViewById(R.id.YES); RelativeLayout noButton = window.findViewById(R.id.NO); // 设置确定按钮点击事件 yesButton.setOnClickListener(v -> { mSelectedYear = dpPicker.getYear(); mSelectedMonth = dpPicker.getMonth(); mSelectedDay = dpPicker.getDayOfMonth(); updateDateDisplay(); dlg.dismiss(); }); // 设置取消按钮点击事件 noButton.setOnClickListener(v -> dlg.dismiss()); } private void extractParametersFromIntent() { Bundle extras = getIntent().getExtras(); if (extras != null) { mAppKey = extras.getString(KEY_APPKEY, ""); mDeviceSerial = extras.getString(KEY_SERIAL, ""); mVerifyCode = extras.getString(KEY_VERIFYCODE, ""); mAccessToken = extras.getString(KEY_ACCESSTOKEN, ""); mCameraNo = extras.getInt(KEY_CAMERANO, 0); Log.d(TAG, "Received parameters:"); Log.d(TAG, "AppKey: " + mAppKey); Log.d(TAG, "DeviceSerial: " + mDeviceSerial); Log.d(TAG, "VerifyCode: " + mVerifyCode); Log.d(TAG, "AccessToken: " + mAccessToken); Log.d(TAG, "CameraNo: " + mCameraNo); } else { Log.e(TAG, "No parameters received from intent"); } } }
最新发布
06-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值