Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by Redalin ( 14 years ago )
I have this button for choosing the hair:
button3.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// PAR
imgb1.setBackgroundDrawable(d);
gridview.smoothScrollBy(4000, 400);
button3.setPressed(true);
bp = 3;
setTab(3);
// adapter.notifyDataSetChanged();
// gridview.setAdapter(adapter);
resetImageBut();
if (getS() == 1) {
culori[0] = 0xff000000;
culori[1] = 0xff3b2a13;
culori[2] = 0xff754D29;
culori[3] = 0xffFDD50C;
culori[4] = 0xffD49700;
culori[5] = 0xffA68F5A;
culori[6] = 0xffE91C1C;
culori[7] = 0xff009E8E;
culori[8] = 0xff00A1E4;
culori[9] = 0xff462E9C;
} else if (getS() == 2){
culori[0] = 0xff000000;
culori[1] = 0xff3b2a13;
culori[2] = 0xff754D29;
culori[3] = 0xffFDD50C;
culori[4] = 0xffD49700;
culori[5] = 0xffEC3B86;
culori[6] = 0xff35D3A8;
culori[7] = 0xff00A1E4;
culori[8] = 0xffE91A46;
culori[9] = 0xff6A3190;
}
imgb1.getBackground().setColorFilter(culori[0],
PorterDuff.Mode.MULTIPLY);
imgb2.getBackground().setColorFilter(culori[1],
PorterDuff.Mode.MULTIPLY);
imgb3.getBackground().setColorFilter(culori[2],
PorterDuff.Mode.MULTIPLY);
imgb4.getBackground().setColorFilter(culori[3],
PorterDuff.Mode.MULTIPLY);
imgb5.getBackground().setColorFilter(culori[4],
PorterDuff.Mode.MULTIPLY);
imgb6.getBackground().setColorFilter(culori[5],
PorterDuff.Mode.MULTIPLY);
imgb7.getBackground().setColorFilter(culori[6],
PorterDuff.Mode.MULTIPLY);
imgb8.getBackground().setColorFilter(culori[7],
PorterDuff.Mode.MULTIPLY);
imgb9.getBackground().setColorFilter(culori[8],
PorterDuff.Mode.MULTIPLY);
imgb10.getBackground().setColorFilter(culori[9],
PorterDuff.Mode.MULTIPLY);
// imgb10.setVisibility(View.GONE);
button4.setPressed(false);
button5.setPressed(false);
button6.setPressed(false);
button7.setPressed(false);
button8.setPressed(false);
button9.setPressed(false);
setColor(culori[0]);
gridview.setAdapter(adapter);
adapter.notifyDataSetChanged();
adapter.notifyDataSetInvalidated();
mGLView.invalidate();
//culori[0] = 0xfffaf3e6;
return true;
}
});
As you can see, when getS()==1 (the male) the last color is: culori[9] = 0xff462E9C;
The imgb10 (image button to change the color into culori[9] is:
imgb10.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// gridview.smoothScrollBy(4000, 400);
setColor(culori[9]);
if (getS() == 1) {//MAN
if (bp == 3) {
hairRm = (float) (70.0/255.0);
hairGm = (float) (46.0/255.0);
hairBm = (float) (156.0/255.0);
gridview.setAdapter(adapter);
adapter.notifyDataSetChanged();
}else if (getS() == 2) {//WOMAN
if (bp == 3) {
hairR = (float) (106.0/255.0);
hairG = (float) (49.0/255.0);
hairB = (float) (111.0/255.0);
gridview.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
}}}
And the ImageAdapter is:
package hello.project;
import android.content.Context;
import android.graphics.PorterDuff.Mode;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds3.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
convertView = imageView = new ImageView(mContext);
imageView = new ImageView(mContext);
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setAdjustViewBounds(true);
imageView.setMaxWidth(20);
imageView.setMaxHeight(100);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(10,10,10,10);
convertView.setTag(imageView);
imageView.setColorFilter(Project.getColor(), Mode.MULTIPLY);
} else {
imageView = (ImageView) convertView;
}
if(Project.getS()==2){
imageView.setImageResource(mThumbIds3[position]);
}
if(Project.getS()==1){
imageView.setImageResource(mThumbIds3m[position]);
}
return imageView;
}
// references to our images
private Integer[] mThumbIds3 = {
R.drawable.girl_hair_01, R.drawable.girl_hair_02,
R.drawable.girl_hair_03, R.drawable.girl_hair_04,
R.drawable.girl_hair_05, R.drawable.girl_hair_06,
R.drawable.girl_hair_07, R.drawable.girl_hair_08,
R.drawable.girl_hair_09, R.drawable.girl_hair_10,
};
private Integer[] mThumbIds3m = {
R.drawable.boy_hair_0, R.drawable.boy_hair_1,
R.drawable.boy_hair_2, R.drawable.boy_hair_3,
R.drawable.boy_hair_4, R.drawable.boy_hair_5,
R.drawable.boy_hair_6, R.drawable.boy_hair_7,
R.drawable.boy_hair_8, R.drawable.boy_hair_9,
};
}
But the color is not the same in the imageadapter for the gridview, like the color of the button.
Even though 0xff462E9C it is translated into Red: 70 G:46 B:156 as i did.
Revise this Paste