如何从AmbilWarnaDialog中保存所选颜色? 现在我只有这个:
package com.test.testColorPicter;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.test.testColorPicter.AmbilWarnaDialog.OnAmbilWarnaListener;
//http://code.google.com/p/android-color-picker/
public class ColorPicter extends Activity implements OnClickListener {
/** Called when the activity is first created. */
private static final String COLOR_PREFERENCE_KEY = "color";
OnAmbilWarnaListener Listener;
public TextView tv;
Button back;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.tvHello);
back = (Button) findViewById(R.id.bBack);
back.setOnClickListener(this);
final int color = PreferenceManager.getDefaultSharedPreferences(
ColorPicter.this).getInt(COLOR_PREFERENCE_KEY, Color.WHITE);
tv.setTextColor(color);
findViewById(R.id.bu).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AmbilWarnaDialog dialog = new AmbilWarnaDialog(
ColorPicter.this, 222, new OnAmbilWarnaListener() {
@Override
public void onCancel(AmbilWarnaDialog dialog) {
// TODO Auto-generated method stub
Log.i("", "");
}
@Override
public void onOk(AmbilWarnaDialog dialog, int color) {
// TODO Auto-generated method stub
tv.setTextColor(color);
Toast.makeText(getApplicationContext(),
"Saved", Toast.LENGTH_LONG).show();
dialog.show();
}
});
dialog.show();
}
});
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent start = new Intent(this, Main.class);
startActivity(start);
}
}
按OK键保存文字时如何制作?现在我看到变色,但我无法保存。 请帮忙!。感谢
按OK键将文字保存在其中时如何制作?
请帮忙!感谢