0
我有这样的活动和构建列表视图...从列表视图我只能设计一个单行,但现在我想改变的全背景颜色的XML表示充分活动的颜色....更改完整活动的背景?
public class MyActivity extends Activity implements
AdapterView.OnItemClickListener, View.OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListView list = new ListView(this);
setContentView(list);
String[] items = { "Tom", "Sally", "Bill", "John", "Santiago",
"Isabella" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.review, R.id.textView1, items) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = super.getView(position, convertView, parent);
View text = row.findViewById(R.id.seemore);
text.setTag(position);
text.setOnClickListener(MyActivity.this);
View left = row.findViewById(R.id.imageView1);
left.setBackgroundResource(R.drawable.newapture);
left.setTag(position);
left.setOnClickListener(MyActivity.this);
return row;
}
};
和XML代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#272727">
<ImageView
android:id="@+id/one"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/title"
android:layout_marginLeft="15dp"
android:layout_marginTop="14dp"
android:clickable="true"
/>
</RelativeLayout>
这里#272727改变单列的颜色......我想改变的背景。
任何帮助,请...
请问您的活动都有自己的布局文件?然后你可以在那里设置背景。在这里,我看到你只有在你的活动列表视图 –
尝试使用“FILL_PARENT”而不是“match_parent” – Robert