主頁 > 資料庫 > AS開發工程軟體

AS開發工程軟體

2020-10-09 20:06:23 資料庫

  1. AS開發工程軟體
  2. 利用ANDROID STUDIO開發軟體;

主要內容:
1、開發UI界面
2、使用SPINNER
3、使用資料保存技術

直接上代碼:
UI界面:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_weight="1"
    tools:ignore="UselessParent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="#FB8C00"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_gravity="center|bottom"
                android:paddingTop="5dp"
                android:text="支架最大允許跨度查詢"
                android:textColor="#000000"
                android:textSize="20sp"
                android:textStyle="bold" />
        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginBottom="0dp"
            android:background="#00ffffff"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textView2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="left"
                android:text="輸入基礎引數:"
                android:textColor="#000000"
                android:textSize="18sp"
                android:textStyle="bold" />
        </LinearLayout>
        <!--輸入管道材質-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_GDRTXYYL101"
                style="@style/styles_textView"
                android:text="熱態許用應力:" />
            <EditText
                android:id="@+id/textView_GDRTXYYL103"
                style="@style/styles_textView"
                android:text="熱應力" />

            <Spinner
                android:id="@+id/GDRTXYYL_spinner102"
                style="@style/life_spinner_style"
                android:gravity="center"
                android:spinnerMode="dialog"
                tools:ignore="MissingConstraints"
                android:layout_weight="1"
                />


        </LinearLayout>
        <!--輸入管道內襯材質-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_GDTXML101"
                style="@style/styles_textView"
                android:text="管道彈性模量:" />
            <EditText
                android:id="@+id/textView_GDTXML103"
                style="@style/styles_textView"
                android:text="模量:" />

            <Spinner
                android:id="@+id/GDTXML_spinner102"
                style="@style/life_spinner_style"
                android:gravity="center"
                android:spinnerMode="dialog"
                tools:ignore="MissingConstraints"
                android:layout_weight="1"
                />


        </LinearLayout>

        <!--輸入管道焊縫系數-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_gdhfxs101"
                style="@style/styles_textView"
                android:text="橫向焊縫系數:" />
            <EditText
                android:id="@+id/textView_gdhfxs103"
                style="@style/styles_textView"
                android:text="模量:" />

            <Spinner
                android:id="@+id/gdhfxs_spinner102"
                style="@style/life_spinner_style"
                android:gravity="center"
                android:spinnerMode="dialog"
                tools:ignore="MissingConstraints" />

        </LinearLayout>

        <!--輸入管道外徑-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_gdwj101"
                style="@style/styles_textView"
                android:text="選擇管道外徑:" />

            <Spinner
                android:id="@+id/gdwj_spinner102"
                style="@style/life_spinner_style"
                android:gravity="center"
                android:spinnerMode="dialog"
                tools:ignore="MissingConstraints" />

            <TextView
                android:id="@+id/textView_gdwjl103"
                style="@style/styles_textView"
                android:layout_weight="1"
                android:text="    mm" />
        </LinearLayout>

        <!--輸入管道壁厚-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_gdbh101"
                style="@style/styles_textView"
                android:text="選擇管道壁厚:" />

            <Spinner
                android:id="@+id/gdbh_spinner102"
                style="@style/life_spinner_style"
                android:gravity="center"
                android:spinnerMode="dialog"
                tools:ignore="MissingConstraints" />

            <TextView
                android:id="@+id/textView_gdbh103"
                style="@style/styles_textView"
                android:layout_weight="1"
                android:text="    mm" />
        </LinearLayout>




        <!--輸入管道線荷載-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_GDJSHZ101"
                style="@style/styles_textView"
                android:text="管道的線荷載:"
                android:textColor="#FB8C00"/>

            <EditText
                android:id="@+id/textView_GDJSHZ102"
                style="@style/styles_editText"
                android:hint="待輸入"
                android:text="112" />


            <TextView
                android:id="@+id/textView_GDJSHZ103"
                style="@style/styles_textView"
                android:layout_weight="1"
                android:text="kg/m" />
        </LinearLayout>

        <!--輸入管道放水坡度-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_GDFSPD101"
                style="@style/styles_textView"
                android:text="管道放水坡度:"
                android:textColor="#FB8C00"/>

            <EditText
                android:id="@+id/textView_GDFSPD102"
                style="@style/styles_editText"
                android:hint="待輸入"
                android:text="0.002" />


        </LinearLayout>


        <!--點擊事件,求溫度降,-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical">

            <Button
                android:id="@+id/button_LDSWJ11"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_margin="8dp"
                android:background="#403F3B"
                android:paddingLeft="5dp"
                android:paddingRight="5dp"
                android:text="AICAT來查詢"
                android:textColor="#FB8C00"
                android:textSize="20sp"
                android:textStyle="bold" />
        </LinearLayout>

        <!--輸出管道截面系數-->
        <LinearLayout
            android:layout_height="40dp"
            android:layout_width="match_parent"
            android:paddingLeft="5dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_GDHZ101"
                style="@style/styles_textView_sc"
                android:text="管道截面系數:"
                />
            <TextView
                android:id="@+id/textView_GDHZ102"
                style="@style/styles_textView_DATA"
                android:hint="待計算"

                />

            <TextView
                android:id="@+id/textView_GDHZ103"
                style="@style/styles_textView"
                android:text="cm3"
                android:layout_weight="1"
                />
        </LinearLayout>

        <!--輸出管道截面二次距-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            android:paddingLeft="5dp"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_JMECJ101"
                style="@style/styles_textView_sc"
                android:text="截面的二次矩:" />

            <TextView
                android:id="@+id/textView_JMECJ102"
                style="@style/styles_textView_DATA"
                android:hint="待計算"
                android:text="" />

            <TextView
                android:id="@+id/textView_JMECJ103"
                style="@style/styles_textView"
                android:text="cm4" />

        </LinearLayout>



        <!--輸出強度條件下最大跨度-->
        <LinearLayout
            android:layout_height="40dp"
            android:layout_width="match_parent"
            android:paddingLeft="5dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_QDZDKD101"
                style="@style/styles_textView_sc"
                android:text="強度Lmax:"
                />
            <TextView
                android:id="@+id/textView_QDZDKD102"
                style="@style/styles_textView_DATA"
                android:hint="待計算"

                />

            <TextView
                android:id="@+id/textView_QDZDKD103"
                style="@style/styles_textView"
                android:text="m"
                android:layout_weight="1"
                />
        </LinearLayout>

        <!--輸出剛度條件下最大跨度-->
        <LinearLayout
            android:layout_height="40dp"
            android:layout_width="match_parent"
            android:paddingLeft="5dp"
            android:layout_margin="5dp"
            android:background="#FFFFFF"
            tools:ignore="RtlSymmetry">

            <TextView
                android:id="@+id/textView_GDYXKD101"
                style="@style/styles_textView_sc"
                android:text="剛度Lmax:"
                />
            <TextView
                android:id="@+id/textView_GDYXKD102"
                style="@style/styles_textView_DATA"
                android:hint="待計算"

                />

            <TextView
                android:id="@+id/textView_GDYXKD103"
                style="@style/styles_textView"
                android:text="m"
                android:layout_weight="1"
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginBottom="0dp"
            android:background="#00ffffff"
            android:orientation="vertical">

            <TextView
                android:id="@+id/textViewqt"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="left"
                android:text="操作說明:"
                android:textColor="#000000"
                android:textSize="18sp"
                android:textStyle="bold" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_margin="5dp"

            android:orientation="vertical">


            <TextView
                android:id="@+id/textView_yjbz2022"
                style="@style/styles_textView_miaoshu"
                android:text="@string/dgkdsm"/>

        </LinearLayout>


    </LinearLayout>

</ScrollView>

JAVA代碼:
final Spinner GDRTXYYL_Spinner,gdwj_Spinner,gdbh_Spinner,GDTXML_Spinner,gdhfxs_Spinner;
final double ρ_GD;
//旋轉螢屏時候不刷資料;
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
//ID所有輸入的引數;
final EditText textView_GDJSHZ102 = (EditText) findViewById(R.id.textView_GDJSHZ102);
final EditText textView_GDFSPD102 = (EditText) findViewById(R.id.textView_GDFSPD102);
/final EditText textView_BWHD102 = (EditText) findViewById(R.id.textView_BWHD102);
final EditText textView_BWMD102 = (EditText) findViewById(R.id.textView_BWMD102);
final EditText textView_GDNCHD102 = (EditText) findViewById(R.id.textView_GDNCHD102);
/

    //獲取sharedpreferences物件;
    final SharedPreferences sp=getSharedPreferences("LDS_CS",MODE_PRIVATE);
    //初始化;

    String GDJSHZ102=sp.getString("GDJSHZ102","110");
    String GDFSPD102=sp.getString("GDFSPD102","0.002");
    /*String BWHD102=sp.getString("BWHD102","100");
    String BWMD102=sp.getString("BWMD102","250");
    String GDNCHD102=sp.getString("GDNCHD102","0");*/
    //讀取存盤檔案到該格上;

    textView_GDJSHZ102.setText(GDJSHZ102);
    textView_GDFSPD102.setText(GDFSPD102);
    /*textView_BWHD102.setText(BWHD102);
    textView_BWMD102.setText(BWMD102);
    textView_GDNCHD102.setText(GDNCHD102);*/



    //選擇常用鋼管的熱態許用應力,
    GDRTXYYL_Spinner = (Spinner) super.findViewById(R.id.GDRTXYYL_spinner102);//從這個ID入口,彈出下列串列界面;
    //以下為靜態的賦值
    GDRTXYYL_Spinner.setPrompt("常用鋼管的熱態許用應力:");//顯示在下列式選單內的第一行
    ArrayList<CharSequence> GDRTXYYL_List = new ArrayList<CharSequence>();//配接器指定資源,申明一個下拉式數值配接器,
    GDRTXYYL_List.add("MPa,20#,-20~100°C,130MPa");//賦值每個的值
    GDRTXYYL_List.add("MPa,20#,100~150°C,130MPa");
    GDRTXYYL_List.add("MPa,20#,150~200°C,123MPa");
    GDRTXYYL_List.add("MPa,20#,200~250°C,110MPa");
    GDRTXYYL_List.add("MPa,20#,250~300°C,101MPa");
    GDRTXYYL_List.add("MPa,20#,300~350°C,92MPa");
    GDRTXYYL_List.add("MPa,20#,350~400°C,86MPa");

    /*GDRTXYYL_List.add("MPa,Q235A,-20~100°C,113MPa");//賦值每個的值
    GDRTXYYL_List.add("MPa,Q235A,100~150°C,113MPa");
    GDRTXYYL_List.add("MPa,Q235A,150~200°C,105MPa");
    GDRTXYYL_List.add("MPa,Q235A,200~250°C,94MPa");
    GDRTXYYL_List.add("MPa,Q235A,250~300°C,86MPa");
    GDRTXYYL_List.add("MPa,Q235A,300~350°C,77MPa");*/





    ArrayAdapter<CharSequence> GDRTXYYL_Adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item,GDRTXYYL_List);
    //第二種:設定拉數值的值后,把數值組封裝到配接器的容器中去,其語法為:
    // List< CharSequence > list=new ArrayList< CharSequence >();
    //list. add();
    //ArrayAdapter <CharSequence> adapter =ArrayAdapter.createFromResource(this,串列顯示的樣式,集合資料[list]);
    GDRTXYYL_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//設定陣列配接器的布局樣式;
    GDRTXYYL_Spinner.setAdapter(GDRTXYYL_Adapter);//設定下拉式框的簡單配接器
    GDRTXYYL_Spinner.setSelection(3-1);//設定默認顯示的行

    GDRTXYYL_Spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        //設定點擊事件的監聽器
        private AdapterView<?> parent;
        private View view;
        private int position;
        private long id;
        final TextView textView_GDRTXYYL103 = (TextView) findViewById(R.id.textView_GDRTXYYL103);//定義一個TextView;

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            //System.out.println(spinner==parent);//true
            //System.out.println(view);
            //String data = adapter.getItem(position);//從配接器中獲取被選擇的資料項
            //String data = list.get(position);//從集合中獲取被選擇的資料項
            String data = (String)GDRTXYYL_Spinner.getItemAtPosition(position);//從spinner中獲取被選擇的資料
            if (data == "MPa,20#,-20~100°C,130MPa") {
                textView_GDRTXYYL103.setText("130");
            } else if (data == "MPa,20#,100~150°C,130MPa") {
                textView_GDRTXYYL103.setText("130");
            } else if (data == "MPa,20#,150~200°C,123MPa") {
                textView_GDRTXYYL103.setText("123");
            }else if (data == "MPa,20#,200~250°C,110MPa") {
                textView_GDRTXYYL103.setText("110");
            }else if (data == "MPa,20#,250~300°C,101MPa") {
                textView_GDRTXYYL103.setText("101");
            }else if (data == "MPa,20#,300~350°C,92MPa") {
                textView_GDRTXYYL103.setText("92");
            }else if (data == "MPa,20#,350~400°C,86MPa") {
                textView_GDRTXYYL103.setText("86");

            }
        }
        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub
        }
    });




    //選擇管道彈性模量,
    GDTXML_Spinner = (Spinner) super.findViewById(R.id.GDTXML_spinner102);//從這個ID入口,彈出下列串列界面;
    //以下為靜態的賦值
    GDTXML_Spinner.setPrompt("請選擇管道彈性模量:");//顯示在下列式選單內的第一行
    ArrayList<CharSequence> GDTXML_List = new ArrayList<CharSequence>();//配接器指定資源,申明一個下拉式數值配接器,
    GDTXML_List.add("x1000MPa,碳鋼,-20~0°C,194");//賦值每個的值
    GDTXML_List.add("x1000MPa,碳鋼,0~20°C,192");
    GDTXML_List.add("x1000MPa,碳鋼,20~100°C,191");
    GDTXML_List.add("x1000MPa,碳鋼,100~150°C,189");
    GDTXML_List.add("x1000MPa,碳鋼,150~200°C,186");
    GDTXML_List.add("x1000MPa,碳鋼,200~250°C,183");


    ArrayAdapter<CharSequence> GDTXML_Adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item,GDTXML_List);
    //第二種:設定拉數值的值后,把數值組封裝到配接器的容器中去,其語法為:
    // List< CharSequence > list=new ArrayList< CharSequence >();
    //list. add();
    //ArrayAdapter <CharSequence> adapter =ArrayAdapter.createFromResource(this,串列顯示的樣式,集合資料[list]);
    GDTXML_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//設定陣列配接器的布局樣式;
    GDTXML_Spinner.setAdapter(GDTXML_Adapter);//設定下拉式框的簡單配接器
    GDTXML_Spinner.setSelection(5-1);//設定默認顯示的行

    GDTXML_Spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        //設定點擊事件的監聽器
        private AdapterView<?> parent;
        private View view;
        private int position;
        private long id;
        final TextView textView_GDTXML103 = (TextView) findViewById(R.id.textView_GDTXML103);//定義一個TextView;

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String data = (String)GDTXML_Spinner.getItemAtPosition(position);//從spinner中獲取被選擇的資料
            if (data == "x1000MPa,碳鋼,-20~0°C,194") {
                textView_GDTXML103.setText("194");
            } else if (data == "x1000MPa,碳鋼,0~20°C,192") {
                textView_GDTXML103.setText("192");
            } else if (data == "x1000MPa,碳鋼,20~100°C,191") {
                textView_GDTXML103.setText("191");
            } else if (data == "x1000MPa,碳鋼,100~150°C,189") {
                textView_GDTXML103.setText("189");
            } else if (data == "x1000MPa,碳鋼,150~200°C,186") {
                textView_GDTXML103.setText("186");
            } else if (data == "x1000MPa,碳鋼,200~250°C,183") {
                textView_GDTXML103.setText("183");
            } else if (data == "x1000MPa,碳鋼,250~300°C,179") {
                textView_GDTXML103.setText("179");
            } else if (data == "x1000MPa,碳鋼,300~350°C,173") {
                textView_GDTXML103.setText("173");
            } else if (data == "x1000MPa,碳鋼,350~400°C,165") {
                textView_GDTXML103.setText("165");


            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub
        }
    });




    //選擇管道外徑,
    gdwj_Spinner = (Spinner) super.findViewById(R.id.gdwj_spinner102);//從這個ID入口,彈出下列串列界面;
    //以下為靜態的賦值
    gdwj_Spinner.setPrompt("請選擇管道外徑:");//顯示在下列式選單內的第一行
    ArrayList<CharSequence> gdwj_List = new ArrayList<CharSequence>();//配接器指定資源,申明一個下拉式數值配接器,
    gdwj_List.add("20");//賦值每個的值
    gdwj_List.add("25");
    gdwj_List.add("32");
    gdwj_List.add("38");
    gdwj_List.add("45");
    gdwj_List.add("57");
    gdwj_List.add("76");
    gdwj_List.add("89");
    gdwj_List.add("108");
    gdwj_List.add("133");
    gdwj_List.add("159");
    gdwj_List.add("219");
    gdwj_List.add("273");
    gdwj_List.add("325");
    gdwj_List.add("377");
    gdwj_List.add("426");



    ArrayAdapter<CharSequence> gdwj_Adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, gdwj_List);
    //第二種:設定拉數值的值后,把數值組封裝到配接器的容器中去,其語法為:
    // List< CharSequence > list=new ArrayList< CharSequence >();
    //list. add();
    //ArrayAdapter <CharSequence> adapter =ArrayAdapter.createFromResource(this,串列顯示的樣式,集合資料[list]);
    gdwj_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//設定陣列配接器的布局樣式;
    gdwj_Spinner.setAdapter(gdwj_Adapter);//設定下拉式框的簡單配接器
    gdwj_Spinner.setSelection(12-1);//設定默認顯示的行


    //選擇管道壁厚
    gdbh_Spinner = (Spinner) super.findViewById(R.id.gdbh_spinner102);//從這個ID入口,彈出下列串列界面;
    //以下為靜態的賦值
    gdbh_Spinner.setPrompt("請選擇管道壁厚:");//顯示在下列式選單內的第一行
    ArrayList<CharSequence> gdbh_List = new ArrayList<CharSequence>();//配接器指定資源,申明一個下拉式數值配接器,
    gdbh_List.add("2");//賦值每個的值
    gdbh_List.add("2.5");
    gdbh_List.add("3");
    gdbh_List.add("3.5");
    gdbh_List.add("4");
    gdbh_List.add("4.5");
    gdbh_List.add("5");
    gdbh_List.add("6");
    gdbh_List.add("7");
    gdbh_List.add("8");
    gdbh_List.add("9");
    gdbh_List.add("10");
    gdbh_List.add("11");
    gdbh_List.add("12");
    gdbh_List.add("14");
    gdbh_List.add("16");



    ArrayAdapter<CharSequence> gdbh_Adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, gdbh_List);
    //第二種:設定拉數值的值后,把數值組封裝到配接器的容器中去,其語法為:
    // List< CharSequence > list=new ArrayList< CharSequence >();
    //list. add();
    //ArrayAdapter <CharSequence> adapter =ArrayAdapter.createFromResource(this,串列顯示的樣式,集合資料[list]);
    gdbh_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//設定陣列配接器的布局樣式;
    gdbh_Spinner.setAdapter(gdbh_Adapter);//設定下拉式框的簡單配接器
    gdbh_Spinner.setSelection(8-1);//設定默認顯示的行



    //選擇橫向焊縫系數;
    gdhfxs_Spinner = (Spinner) super.findViewById(R.id.gdhfxs_spinner102);//從這個ID入口,彈出下列串列界面;
    //以下為靜態的賦值
    gdhfxs_Spinner.setPrompt("請選擇管道壁厚:");//顯示在下列式選單內的第一行
    ArrayList<CharSequence> gdhfxs_List = new ArrayList<CharSequence>();//配接器指定資源,申明一個下拉式數值配接器,
    gdhfxs_List.add("手工有墊環對焊,k=0.9");//賦值每個的值
    gdhfxs_List.add("手工無墊環對焊,k=0.7");
    gdhfxs_List.add("手工雙面加強焊,k=0.95");
    gdhfxs_List.add("自動雙面焊,k=1.0");
    gdhfxs_List.add("自動單面焊,k=0.8");




    ArrayAdapter<CharSequence> gdhfxs_Adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, gdhfxs_List);
    //第二種:設定拉數值的值后,把數值組封裝到配接器的容器中去,其語法為:
    // List< CharSequence > list=new ArrayList< CharSequence >();
    //list. add();
    //ArrayAdapter <CharSequence> adapter =ArrayAdapter.createFromResource(this,串列顯示的樣式,集合資料[list]);
    gdhfxs_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);//設定陣列配接器的布局樣式;
    gdhfxs_Spinner.setAdapter(gdhfxs_Adapter);//設定下拉式框的簡單配接器
    gdhfxs_Spinner.setSelection(2-1);//設定默認顯示的行

    gdhfxs_Spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        //設定點擊事件的監聽器
        private AdapterView<?> parent;
        private View view;
        private int position;
        private long id;
        final TextView textView_gdhfxs103 = (TextView) findViewById(R.id.textView_gdhfxs103);//定義一個TextView;

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String data = (String)gdhfxs_Spinner.getItemAtPosition(position);//從spinner中獲取被選擇的資料
            if (data == "手工有墊環對焊,k=0.9") {
                textView_gdhfxs103.setText("0.9");
            } else if (data == "手工無墊環對焊,k=0.7") {
                textView_gdhfxs103.setText("0.7");
            } else if (data == "手工雙面加強焊,k=0.95") {
                textView_gdhfxs103.setText("0.95");
            } else if (data == "自動雙面焊,k=1.0") {
                textView_gdhfxs103.setText("1.0");
            } else if (data == "自動單面焊,k=0.8") {
                textView_gdhfxs103.setText("0.8");
            }

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub
        }
    });






    //計算保溫附屬材料;

    Button button_bwcl12 = findViewById(R.id.button_LDSWJ11);
    button_bwcl12.setOnClickListener(new View.OnClickListener() {

        /**
         * Called when a view has been clicked.
         *
         * @param v The view that was clicked.
         */
        @Override
        public void onClick(View v) {

            //判斷文本輸入框是否為空;
            //判斷文本框是否為空;
            //final EditText textView_drxs102 = (EditText) findViewById(R.id.textView_drxs102);
            //final EditText textView_RSS102 = (EditText) findViewById(R.id.textView_RSS102);

            String STR101 = textView_GDJSHZ102.getText().toString();
            String STR102 = textView_GDFSPD102.getText().toString();
            /*String STR103 = textView_BWHD102.getText().toString();
            String STR104 = textView_BWMD102.getText().toString();
            String STR105 = textView_GDNCHD102.getText().toString();*/


            /*String STR105 = textView_GNWD102.getText().toString();
            String STR106 = textView_HJWD102.getText().toString();*/

            //保存編輯框資料;
            SharedPreferences.Editor editor=sp.edit();
            editor.putString("GDJSHZ102",STR101);//保存引數
            editor.putString("GDFSPD102",STR102);//保存引數
            /*editor.putString("BWHD102",STR103);//保存引數
            editor.putString("BWMD102",STR104);//保存引數
            editor.putString("GDNCHD102",STR105);//保存引數*/
            /*editor.putString("HJWD",STR106);//保存引數*/


            editor.commit();//提交資訊;
            //Toast.makeText(Lengdongshui_WS.this,"已經保存資料",Toast.LENGTH_LONG).show();


            if (
                    TextUtils.isEmpty(STR101)|
                            TextUtils.isEmpty(STR102)
                            ) {
                Toast.makeText(Zhijiakuadu_Lmax.this, "AICAT提示::-),鏟屎官大人,檢查引數是否為空,",
                        Toast.LENGTH_SHORT).show();

            }
            else {

                //提取管道外徑;
                Spinner spinner_wj=(Spinner)findViewById(R.id.gdwj_spinner102);
                String string_wj =(String)spinner_wj.getSelectedItem();
                final double Dn= Double.parseDouble(string_wj);
                //提取管道壁厚;
                Spinner spinner_GDBH=(Spinner)findViewById(R.id.gdbh_spinner102);
                String string_GDBH =(String)spinner_GDBH.getSelectedItem();
                final double S1= Double.parseDouble(string_GDBH);

                //提取管道的許用應力;
                EditText textView_GDRTXYYL103 = (EditText) findViewById(R.id.textView_GDRTXYYL103);
                double YL = Double.parseDouble(textView_GDRTXYYL103.getText().toString());

                //提取管道彈性模量;
                EditText textView_GDTXML103 = (EditText) findViewById(R.id.textView_GDTXML103);
                double Tm = Double.parseDouble(textView_GDTXML103.getText().toString());

                //提取焊縫系數;
                EditText textView_gdhfxs103 = (EditText) findViewById(R.id.textView_gdhfxs103);
                double K = Double.parseDouble(textView_gdhfxs103.getText().toString());

                //提取管道基本荷載;
                EditText textView_GDJSHZ102 = (EditText) findViewById(R.id.textView_GDJSHZ102);
                double q = Double.parseDouble(textView_GDJSHZ102.getText().toString());


                //提取管道坡度;
                EditText textView_GDFSPD102 = (EditText) findViewById(R.id.textView_GDFSPD102);
                double i = Double.parseDouble(textView_GDFSPD102.getText().toString());


               //計算強度條件下LMAX;
                double L_QD=2.24*Math.sqrt(W*K*YL/(q*9.8));
                //顯示R1輸出,保留3位小數
                double double_31 = L_QD*100;
                int int_32= (int) double_31;
                double data33 = (double) int_32 /100;
                String STR_34 = String.valueOf(data33);
                //輸出到指定位置
                TextView textView_QDZDKD102= (TextView) findViewById(R.id.textView_QDZDKD102);
                textView_QDZDKD102.setText(STR_34);


                //計算剛度條件下LMAX;
                double L_GD=0.19*Math.cbrt(100*i*Tm*I2*1000/(q*9.8));
                //顯示R1輸出,保留3位小數
                double double_41 = L_GD*100;
                int int_42= (int) double_41;
                double data43 = (double) int_42 /100;
                String STR_44 = String.valueOf(data43);
                //輸出到指定位置
                TextView textView_GDYXKD102= (TextView) findViewById(R.id.textView_GDYXKD102);
                textView_GDYXKD102.setText(STR_44);

            }


        }
    });

    TextView textView131 = (TextView) findViewById(R.id.textView131);
    textView131.setOnClickListener(new View.OnClickListener() {
        /**
         * Called when a view has been clicked.
         *
         * @param v The view that was clicked.
         */
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Zhijiakuadu_Lmax.this, MainActivity008.class);
            startActivity(intent);
        }
    });
}

}

運行界面
在這里插入圖片描述

目前,作者正在開發工程軟體,有興趣的同志,可以加qq18605132私人聊,

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/165002.html

標籤:其他

上一篇:oc專案中使用swift

下一篇:Android WindowManager 全域懸浮窗 + AccessibilityService+ RecyclerView 拖動和點擊

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • GPU虛擬機創建時間深度優化

    **?桔妹導讀:**GPU虛擬機實體創建速度慢是公有云面臨的普遍問題,由于通常情況下創建虛擬機屬于低頻操作而未引起業界的重視,實際生產中還是存在對GPU實體創建時間有苛刻要求的業務場景。本文將介紹滴滴云在解決該問題時的思路、方法、并展示最終的優化成果。 從公有云服務商那里購買過虛擬主機的資深用戶,一 ......

    uj5u.com 2020-09-10 06:09:13 more
  • 可編程網卡芯片在滴滴云網路的應用實踐

    **?桔妹導讀:**隨著云規模不斷擴大以及業務層面對延遲、帶寬的要求越來越高,采用DPDK 加速網路報文處理的方式在橫向縱向擴展都出現了局限性。可編程芯片成為業界熱點。本文主要講述了可編程網卡芯片在滴滴云網路中的應用實踐,遇到的問題、帶來的收益以及開源社區貢獻。 #1. 資料中心面臨的問題 隨著滴滴 ......

    uj5u.com 2020-09-10 06:10:21 more
  • 滴滴資料通道服務演進之路

    **?桔妹導讀:**滴滴資料通道引擎承載著全公司的資料同步,為下游實時和離線場景提供了必不可少的源資料。隨著任務量的不斷增加,資料通道的整體架構也隨之發生改變。本文介紹了滴滴資料通道的發展歷程,遇到的問題以及今后的規劃。 #1. 背景 資料,對于任何一家互聯網公司來說都是非常重要的資產,公司的大資料 ......

    uj5u.com 2020-09-10 06:11:05 more
  • 滴滴AI Labs斬獲國際機器翻譯大賽中譯英方向世界第三

    **桔妹導讀:**深耕人工智能領域,致力于探索AI讓出行更美好的滴滴AI Labs再次斬獲國際大獎,這次獲獎的專案是什么呢?一起來看看詳細報道吧! 近日,由國際計算語言學協會ACL(The Association for Computational Linguistics)舉辦的世界最具影響力的機器 ......

    uj5u.com 2020-09-10 06:11:29 more
  • MPP (Massively Parallel Processing)大規模并行處理

    1、什么是mpp? MPP (Massively Parallel Processing),即大規模并行處理,在資料庫非共享集群中,每個節點都有獨立的磁盤存盤系統和記憶體系統,業務資料根據資料庫模型和應用特點劃分到各個節點上,每臺資料節點通過專用網路或者商業通用網路互相連接,彼此協同計算,作為整體提供 ......

    uj5u.com 2020-09-10 06:11:41 more
  • 滴滴資料倉庫指標體系建設實踐

    **桔妹導讀:**指標體系是什么?如何使用OSM模型和AARRR模型搭建指標體系?如何統一流程、規范化、工具化管理指標體系?本文會對建設的方法論結合滴滴資料指標體系建設實踐進行解答分析。 #1. 什么是指標體系 ##1.1 指標體系定義 指標體系是將零散單點的具有相互聯系的指標,系統化的組織起來,通 ......

    uj5u.com 2020-09-10 06:12:52 more
  • 單表千萬行資料庫 LIKE 搜索優化手記

    我們經常在資料庫中使用 LIKE 運算子來完成對資料的模糊搜索,LIKE 運算子用于在 WHERE 子句中搜索列中的指定模式。 如果需要查找客戶表中所有姓氏是“張”的資料,可以使用下面的 SQL 陳述句: SELECT * FROM Customer WHERE Name LIKE '張%' 如果需要 ......

    uj5u.com 2020-09-10 06:13:25 more
  • 滴滴Ceph分布式存盤系統優化之鎖優化

    **桔妹導讀:**Ceph是國際知名的開源分布式存盤系統,在工業界和學術界都有著重要的影響。Ceph的架構和演算法設計發表在國際系統領域頂級會議OSDI、SOSP、SC等上。Ceph社區得到Red Hat、SUSE、Intel等大公司的大力支持。Ceph是國際云計算領域應用最廣泛的開源分布式存盤系統, ......

    uj5u.com 2020-09-10 06:14:51 more
  • es~通過ElasticsearchTemplate進行聚合~嵌套聚合

    之前寫過《es~通過ElasticsearchTemplate進行聚合操作》的文章,這一次主要寫一個嵌套的聚合,例如先對sex集合,再對desc聚合,最后再對age求和,共三層嵌套。 Aggregations的部分特性類似于SQL語言中的group by,avg,sum等函式,Aggregation ......

    uj5u.com 2020-09-10 06:14:59 more
  • 爬蟲日志監控 -- Elastc Stack(ELK)部署

    傻瓜式部署,只需替換IP與用戶 導讀: 現ELK四大組件分別為:Elasticsearch(核心)、logstash(處理)、filebeat(采集)、kibana(可視化) 下載均在https://www.elastic.co/cn/downloads/下tar包,各組件版本最好一致,配合fdm會 ......

    uj5u.com 2020-09-10 06:15:05 more
最新发布
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:33:24 more
  • MySQL中binlog備份腳本分享

    關于MySQL的二進制日志(binlog),我們都知道二進制日志(binlog)非常重要,尤其當你需要point to point災難恢復的時侯,所以我們要對其進行備份。關于二進制日志(binlog)的備份,可以基于flush logs方式先切換binlog,然后拷貝&壓縮到到遠程服務器或本地服務器 ......

    uj5u.com 2023-04-20 08:28:06 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:27:27 more
  • 快取與資料庫雙寫一致性幾種策略分析

    本文將對幾種快取與資料庫保證資料一致性的使用方式進行分析。為保證高并發性能,以下分析場景不考慮執行的原子性及加鎖等強一致性要求的場景,僅追求最終一致性。 ......

    uj5u.com 2023-04-20 08:26:48 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:26:35 more
  • 云時代,MySQL到ClickHouse資料同步產品對比推薦

    ClickHouse 在執行分析查詢時的速度優勢很好的彌補了MySQL的不足,但是對于很多開發者和DBA來說,如何將MySQL穩定、高效、簡單的同步到 ClickHouse 卻很困難。本文對比了 NineData、MaterializeMySQL(ClickHouse自帶)、Bifrost 三款產品... ......

    uj5u.com 2023-04-20 08:26:29 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:25:13 more
  • Redis 報”OutOfDirectMemoryError“(堆外記憶體溢位)

    Redis 報錯“OutOfDirectMemoryError(堆外記憶體溢位) ”問題如下: 一、報錯資訊: 使用 Redis 的業務介面 ,產生 OutOfDirectMemoryError(堆外記憶體溢位),如圖: 格式化后的報錯資訊: { "timestamp": "2023-04-17 22: ......

    uj5u.com 2023-04-20 08:24:54 more
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:24:03 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:23:11 more