есть MainActivity
в нем FrameLayout, который наполняется фрагментами
Код: Выделить всё
//переключение tab-ов-обработка
Tab_view.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
work_space=getFragmentManager().beginTransaction();
if (tabId=="tab1") {//главный экран
common_screen=new common_frag();
work_space.replace(com.example.acorz.R.id.work_space,common_screen);
}
if (tabId=="tab2") {//экран настроек
change_screen=new change_frag();
work_space.replace(com.example.acorz.R.id.work_space,change_screen);
}
if (tabId=="tab3") {//экран результата
result_screen=new result_frag();
work_space.replace(com.example.acorz.R.id.work_space,result_screen);
}
//work_space.addToBackStack(null);
work_space.commit();// Обновление рабочего поля
}
});
Собственно один класс из фрагментов
Код: Выделить всё
package com.example.acorz;
import android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.WorkSource;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class common_frag extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(com.example.acorz.R.layout.common, container, false );
}
public void about_btn_clk(View v){
AlertDialog.Builder builder=new AlertDialog.Builder(getActivity().getApplicationContext());
builder.setTitle("ERROR")
.setCancelable(false)
.setMessage("ERROR :")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
//work=true;
}
});
AlertDialog alert=builder.create();
alert.show();
}
}
при работе приложения при нажатии на кнопку приложение вылетает
ошибка как я понял выдается изза того что я не верно передаю Context в Builder
как правильно делать так и не понял

