Android: orientation="vertical" android: layout width="match parent"


Download 14.53 Kb.
Sana30.04.2023
Hajmi14.53 Kb.
#1417325
Bog'liq
Royxat actvity


Bu yerdagi royhatda_actvity=va dizaynida:




android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/purple_200"
android:layout_height="wrap_content"
android:gravity="center">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"

android:textSize="30dp"


android:gravity="center">


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="30dp"
android:gravity="center">


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="30dp"
android:gravity="center">


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ADD"
android:layout_margin="50dp">


???????

Bu esa kod qismi:


public class activty_royxatlar extends AppCompatActivity {
ListView listView;
AppCompatButton btn_add;
EditText edit_name;
String[]foyddalanuvchilar={"akbar","san`atbek","diyorbek"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activty_royxatlar);
btn_add=findViewById(R.id.btn_addd);
edit_name=findViewById(R.id.id_edit_name);
listView=findViewById(R.id.list_view);
ArrayAdapterarrayAdapter=new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1);
listView.setAdapter(arrayAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView adapterView, View view, int i, long l) {
Toast.makeText(activty_royxatlar.this,"foyddalanuvchilar[i]",Toast.LENGTH_SHORT).show();
}
});
btn_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!edit_name.getText().toString().equals("")) {
foyddalanuvchilar.equals(edit_name.getText().toString());
edit_name.setText("");
}else {
Toast.makeText(activty_royxatlar.this,"Maydon bosh!",Toast.LENGTH_SHORT);

}
}
});


}
}

Download 14.53 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling