我正在创建使用按钮共享图像的图像共享应用程序。我在下面的代码得到一个unable to resolve the required method error
:如何调用getDrawable方法
public class ShareActivity extends Activity implements View.OnClickListener {
Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_share);
button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(this);
}
private void button1Click()
{
BitmapDrawable bm = (BitmapDrawable) getDrawable(button1);
Bitmap mysharebmp = bm.getBitmap();
String path = Images.Media.insertImage(getContentResolver(),
mysharebmp, "MyImage", null);
在此行中:
BitmapDrawable bm = (BitmapDrawable) getDrawable(button1);ShareActivity
我得到The method getDrawable(Button) is undefined for the type ShareActivity
。为什么我会得到这个错误?完整的代码是here。
你在做什么。 'getDrawable(button1);'你看过api的文档吗?你的问题不清楚。 – Raghunandan
我想要一个按钮,可以分享我的图片社交应用程序,这就是我想要做的先生 –
你的图像在哪里? –