Sreepulari Sreepulari - 1 year ago 93
Android Question

.init(activity); is showing error [android]

i am trying to implement ShineButton in my project . I have successfully synced the library to the gradle and added shine button in the xml.

now when i am trying to write the java code

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

Button b1 = (Button)findViewById(;

b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "Kill bill", Toast.LENGTH_SHORT).show();

ShineButton shineButton = (ShineButton) findViewById(;


.init(activity); is showing cannot resolve symbol activity.

Answer Source

You don't literally copy the code verbatim, you read the documentation and object types supported by the method.

public void init(Activity activity) {

For example, I assume you are running that from an activity based on the usage of findViewById? Then you need "this instance of the Activity"


or an instance of an Activity if you were in a Fragment

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download