我有一个按钮,列表视图和另一个按钮。最初列表视图的属性消失了,所以按钮 2 显示在按钮 1 的下方,当我单击按钮 1 时,按钮 2 应该设置在该屏幕的底部,并且列表应该在两个按钮之间可见.. ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:id="@+id/relativeLayout1" android:layout_height="wrap_content">
<Button android:layout_width="fill_parent" android:id="@+id/Button01"
android:background="#ffffff" android:text="Button"
android:layout_height="40dp"></Button>
<ListView android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/llList"></ListView>
<Button android:layout_height="40dp" android:text="Button"
android:id="@+id/button" android:background="#ffffff"
android:layout_width="fill_parent"></Button>
</RelativeLayout>
</LinearLayout>
活动
package com.app.app.hello;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
public class HelloActivity extends Activity {
ListView llList;
Button btn2,btn1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
llList=(ListView) findViewById(R.id.llList);
llList.setVisibility(View.GONE);
myAdapter adapter=new myAdapter();
llList.setAdapter(adapter);
btn2=(Button) findViewById(R.id.button);
Button btn1=(Button) findViewById(R.id.Button01);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
llList.setVisibility(View.VISIBLE);
}
});
}
class myAdapter extends BaseAdapter
{
public int getCount() {
// TODO Auto-generated method stub
return 5;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View row=View.inflate(HelloActivity.this,R.layout.list_row, null);
// TODO Auto-generated method stub
return row;
}
}
}