Reputation: 401
I have my class in Android
who extends Dialog
public class DialogSearch extends Dialog{
public ImageButton imageButtonCancel ;
public DialogSearch(Context context, int theme) {
super(context, theme);
setContentView(R.layout.finddialog);
imageButtonCancel = (ImageButton) findViewById(R.id.imageButtonFindCancel);
imageButtonCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//hide();
dismiss();
}
});
this.show();
}
}
this is not my ActivityClass
, I can instanciate from my ActivityClass
but when I click imageButtonCancel
to close i doesn't work. I tryed both hide()
and close()
methods.
up date
this is my R.Layout.finddialog
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
>
<AutoCompleteTextView
android:id="@+id/editTextFind"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="write here"
android:textSize="18sp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" />
<ImageButton
android:id="@+id/imageButtonFindSearch"
android:layout_toRightOf="@+id/editTextFind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/find_icone"
android:layout_marginRight="10px"
/>
<ImageButton
android:id="@+id/imageButtonFindCancel"
android:layout_below="@+id/radioGroupeFind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/cancel_icone"
android:layout_alignRight="@+id/imageButtonFindSearch"
/>
</RelativeLayout>
up date
I am calling it from my ActivityClass
public class mapActivity extends Activity {
private ImageButton buttonSearch ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// full screen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
buttonSearch = (ImageButton) findViewById(R.id.buttonSearchMain) ;
buttonSearch.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialogSearch = new DialogSearch(mapActivity.this,R.style.FullHeightDialog); // this for not display dialog title part
}
});
}
}
thanks.
Upvotes: 0
Views: 92
Reputation: 11131
try this... use onCreate() method...
public class DialogSearch extends Dialog {
public DialogSearch(Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// hides title bar...
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.finddialog);
ImageButton imageButtonCancel = (ImageButton) findViewById(R.id.imageButtonFindCancel);
imageButtonCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// hide();
dismiss();
}
});
}
}
Upvotes: 1