I have a manifest error. It was fine at first time. But i chagned it to "public class color_dia extends Dialog implements View.OnClickListener" and it was red line on color_dia in manifest file.
when i click a button related to color_dia. it makes error "java.lang.RuntimeException: Unable to instantiate activity ComponentInfo"
what should i do?
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import static android.graphics.Color.rgb;
public class color_dia extends Dialog implements View.OnClickListener {
private MainActivity mActivity;
public color_dia(Context context) {
super(context);
mActivity = (MainActivity) context;
}
public color_dia(Context context, int themeResId) {
super(context, themeResId);
mActivity = (MainActivity) context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Pick Line Color");
setContentView(R.layout.color_dia);
}
}
You cannot launch a Dialog
using startActivity()
or startActivityForResult()
. You can only launch activities (class that extends Activity
). A Dialog
is shown in an Activity
by calling showDialog()
(or use DialogFragment
). Please read about the difference between Dialog
and Activity
in the Android documentation or find a suitable tutorial to follow.