how to set background color

Put your problem here if it does not fit any of the other categories.

how to set background color

Postby Archana » Wed Mar 19, 2008 10:45 am

Hi plusminus,

i was trying to set background color for list view. i set like dis.bt nothing is coming
.can u tell me how to set color and what value i have to give in place of int color.i attached the code below.

.
private class SpeechView extends LinearLayout {

private Button mButton;

public SpeechView(Context context, String title, String dialogue, boolean expanded) {
super(context);
LinearLayout l1 = new LinearLayout(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
l1.setLayoutParams(lp);
l1.setBackgroundColor(????); // what value i have to set here


//color.setBackgroundColor(32);
this.setOrientation(VERTICAL);
mTitle = new TextView(context);
mTitle.setText(title);
addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

mDialogue = new TextView(context);
mDialogue.setText(dialogue);
addView(mDialogue, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
mDialogue.setVisibility(expanded ? VISIBLE : GONE);

mButton=new Button(context);
mButton.setText("chat");

addView(mButton, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
mButton.setVisibility(expanded ? VISIBLE : GONE);
mButton.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

Intent mI = new Intent(Matching_Profile.this,Chat.class);
startActivity(mI);
}
});
}
Archana
Archana
Experienced Developer
Experienced Developer
 
Posts: 53
Joined: Thu Feb 28, 2008 12:00 pm
Location: Bangalore

Top

Postby Jesmiatka » Wed Mar 19, 2008 11:12 am

Hi,

you should use the Color class

Example:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setBackgroundColor(Color.GRAY);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby rmeph » Wed Mar 19, 2008 11:14 am

if u want set color direct than u will be pass for white color 0xffffffff.
rmeph
Senior Developer
Senior Developer
 
Posts: 121
Joined: Mon Dec 10, 2007 1:54 pm
Location: India

setting bacgoround color

Postby Archana » Wed Mar 19, 2008 12:56 pm

Hi,
i tried as u said.but no change.can u tell me wheather i have to give any other code after this.

LinearLayout l1 = new LinearLayout(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
l1.setLayoutParams(lp);
l1.setBackgroundColor(0xffffffff);
Archana
Archana
Experienced Developer
Experienced Developer
 
Posts: 53
Joined: Thu Feb 28, 2008 12:00 pm
Location: Bangalore

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests