MainActivity java package com xo vaznconvertor
Download 493.34 Kb.
|
XOconvertor
MainActivity.java package com.xo.vaznconvertor;
public class MainActivity extends AppCompatActivity { private double z1 = 0; private ArrayList private LinearLayout linear1;
@Override protected void onCreate(Bundle _savedInstanceState) { super.onCreate(_savedInstanceState); setContentView(R.layout.activity_main); initialize(_savedInstanceState); initializeLogic(); } private void initialize(Bundle _savedInstanceState) { linear1 = (LinearLayout) findViewById(R.id.linear1);
ansBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View _view) { z1 = Double.parseDouble(x1.getText().toString()); if (y1.getSelectedItemPosition() == 0) { if (y2.getSelectedItemPosition() == 0) { x2.setText(x1.getText().toString()); } else { if (y2.getSelectedItemPosition() == 1) { x2.setText(String.valueOf(z1 * 60)); } else { if (y2.getSelectedItemPosition() == 2) { x2.setText(String.valueOf(z1 * 3600)); } else { if (y2.getSelectedItemPosition() == 3) { x2.setText(String.valueOf(z1 * 3600000)); } // else { // Toast.makeText(getApplicationContext(), "Tanlang"); // } } } } } else { if (y1.getSelectedItemPosition() == 1) { if (y2.getSelectedItemPosition() == 0) { x2.setText(String.valueOf(z1 / 60)); } else { if (y2.getSelectedItemPosition() == 1) { x2.setText(x1.getText().toString()); } else { if (y2.getSelectedItemPosition() == 2) { x2.setText(String.valueOf(z1 * 60)); } else { if (y2.getSelectedItemPosition() == 3) { x2.setText(String.valueOf(z1 * 60000)); } // else { // Toast tanlang = Toast.makeText(getApplicationContext(), "Tanlang"); // } } } } } else { if (y1.getSelectedItemPosition() == 2) { if (y2.getSelectedItemPosition() == 0) { x2.setText(String.valueOf(z1 / 3600)); } else { if (y2.getSelectedItemPosition() == 1) { x2.setText(String.valueOf(z1 / 60)); } else { if (y2.getSelectedItemPosition() == 2) { x2.setText(x1.getText().toString()); } else { if (y2.getSelectedItemPosition() == 3) { x2.setText(String.valueOf(z1 * 1000)); } // else { // Toast tanlang = Toast.makeText(getApplicationContext(), "Tanlang"); // } } } } } else { if (y1.getSelectedItemPosition() == 3) { if (y2.getSelectedItemPosition() == 0) { x2.setText(String.valueOf(z1 / 3600000)); } else { if (y2.getSelectedItemPosition() == 1) { x2.setText(String.valueOf(z1 / 60000)); } else { if (y2.getSelectedItemPosition() == 2) { x2.setText(String.valueOf(z1 / 1000)); } else { if (y2.getSelectedItemPosition() == 3) { x2.setText(x1.getText().toString()); } // else { // Toast tanlang = Toast.makeText(getApplicationContext(), "Tanlang"); // } } } } } // else { // Toast tanlang = Toast.makeText(getApplicationContext(), "Tanlang"); // } } } } } }); } private void initializeLogic() { vaqt.add((int)(0), "soat"); vaqt.add((int)(1), "minut"); vaqt.add((int)(2), "second"); vaqt.add((int)(3), "milli second "); y1.setAdapter(new ArrayAdapter ((ArrayAdapter)y1.getAdapter()).notifyDataSetChanged(); y2.setAdapter(new ArrayAdapter ((ArrayAdapter)y2.getAdapter()).notifyDataSetChanged(); } @Override protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { super.onActivityResult(_requestCode, _resultCode, _data); switch (_requestCode) { default:
} } }
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" android:background="@drawable/bgimg__2_" android:gravity="center_horizontal|center_vertical" android:padding="8dp"> android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="77dp" android:layout_marginRight="77dp" android:layout_marginTop="7dp" android:gravity="center" android:orientation="horizontal" android:padding="8dp"> android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal|center_vertical" android:inputType="numberSigned" android:padding="8dp" android:singleLine="true" android:textColor="#39D8C0" android:textColorHint="#39D8C0" android:textSize="25sp" /> android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="8dp" android:spinnerMode="dialog" /> android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|center_vertical" android:layout_marginLeft="77dp" android:layout_marginRight="77dp" android:layout_marginTop="7dp" android:orientation="horizontal" android:gravity="center" android:padding="8dp"> android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal|center_vertical" android:padding="8dp" android:textColor="#39D8C0" android:textSize="25sp" /> android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="8dp" android:spinnerMode="dialog" /> android:id="@+id/ansBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|center_vertical" android:background="@android:color/transparent" android:padding="8dp" android:text="COnvert" android:textColor="#39D8C0" android:textSize="25sp" /> Download 493.34 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling