-3

I've made a basic project for custom toast. Now I want that project to work as a library in my future projects. How do I convert my project into a library? P.S: This is just a dummy project so that I can learn how to create libraries of my own. The code is as follows:

public class CustomActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom);

    Button btn = (Button) findViewById(R.id.button1);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            LayoutInflater inflater = getLayoutInflater();
            View layout = inflater.inflate(R.layout.toast_custom_layout,
                    (ViewGroup) findViewById(R.id.toast_layout_root));

            Toast toast = new Toast(getApplicationContext());
            toast.setGravity(Gravity.BOTTOM, 0, 0);
            toast.setDuration(Toast.LENGTH_LONG);
            toast.setView(layout);
            toast.show();


        }
    });

}

}

2 Answers2

1

If you are using Eclipse

Right Click on Project --> Properties --> Android and Check the Is Library checkbox

Apoorv
  • 13,470
  • 4
  • 27
  • 33
1

Are you using Eclipse? then, project right click->properties->Android->check Is Library(placed in below)

if you are using android studio, In your build.gradle file, use apply plugin: 'com.android.library' not, apply plugin: 'com.android.application'

Cinakyn
  • 648
  • 1
  • 7
  • 20