我对所有这些编码的东西都非常陌生,而且我自己已经走了很远,但我似乎无法弄清楚这个错误。感谢所有帮助。
“范围内无法访问 DonationsActivity 类型的封闭实例”
package com.ganttbros.shadowui;
import org.donations.DonationsActivity;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
public class DonateActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_donate);
final Button donate = (Button) findViewById(R.id.donatebutton);
donate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
startActivity(new Intent(DonationsActivity.this, DonationsActivity.class));
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.donate, menu);
return true;
}
}
我应该告诉你我正在尝试实现这个库:https ://github.com/dschuermann/android-donations-lib#readme 我已经设置了按钮,但我只需要让它启动“DonationsActivity”按下时。