change the size of row of listview in android
I have these files(xml and java code).My listview rows are having a
default size.how can i change this size to smaller or larger uniformly on
each row.
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:orientation="vertical"
>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
>
</ListView>
</LinearLayout>
javafile:
public class Detail extends Activity { private EditText etInput; private
Button btnAdd; private ListView lvItem,lvItem2; private ArrayList
itemArrey; private ArrayAdapter itemAdapter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail);
setUpView();
}
private void setUpView() {
// TODO Auto-generated method stub
// etInput = (EditText)this.findViewById(R.id.editText_input);
btnAdd = (Button)this.findViewById(R.id.button1);
lvItem = (ListView)this.findViewById(R.id.listView1);
lvItem2 = (ListView)this.findViewById(R.id.listView2);
lvItem2.setVisibility(View.INVISIBLE);
itemArrey = new ArrayList<String>();
itemArrey.clear();
itemAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,itemArrey);
lvItem.setAdapter(itemAdapter);
lvItem2.setAdapter(itemAdapter);
btnAdd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
addItemList();
}
});
lvItem.setClickable(true);
lvItem.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
lvItem2.setVisibility(View.VISIBLE);
}
});
}
protected void addItemList() {
itemAdapter.insert("sdsds",0);
itemAdapter.insert("sdddsds",1);
itemAdapter.notifyDataSetChanged();
}
}
No comments:
Post a Comment