2014-12-23 2 views
-3
@Override 
protected void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    this.title = (String) getTitle(); 
    // Getting reference to the DrawerLayout 
    this.drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
    this.drawerList = (ListView) findViewById(R.id.drawer_list); 

    this.fragments[0] = new My_Main_Fragment(this); 
    this.fragments[1] = new My_Breakfast_Fragment(); 
    this.fragments[2] = new My_Lunch_Fragment(); 
    this.fragments[3] = new My_Dinner_Fragment(); 
    this.fragments[4] = new My_Dessert_Fragment(); 
    this.fragments[5] = new My_Seat_Plan_Fragment(); 
    this.fragments[6] = new My_Beverages_Fragment(); 

    this.item_titles = getResources().getStringArray(R.array.menu_items); 

............................................. .................................................. .................................................. .................................................. ...Как подключить список фрагментов Активность с кнопкой нажмите «Основная активность»?

public class My_Seat_Plan_Fragment extends Activity{ 

Button create, edit, view, delete, find;

@Override 
public void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 

    setContentView(R.layout.air_main_interface); 

    create = (Button)findViewById(R.id.note_add); 
    edit = (Button)findViewById(R.id.note_edit); 
    view = (Button)findViewById(R.id.note_view); 
    delet = (Button)findViewById(R.id.note_delete); 
    find = (Button)findViewById(R.id.note_find); 

    create.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 

      Intent in = new Intent(My_Seat_Plan_Fragment.this,Seat_create.class); 
      startActivity(in); 
     } 
    }); 

........................................... .................................................. ...

в ниже прикрепленных два класса мне нужно соединить Основное направление деятельности с классом фрагмента ... Основной деятельности сопровождаются также расширяет активность реализует My_Fragments_Parent {

и фрагмент активность, как следует, как общественный класс My_Seat_Plan_Fragment extends Activity {

, но im получает сообщение об ошибке в основной деятельности в строке

это.фрагменты [5] = новый My_Seat_Plan_Fragment(); ------ говоря, не может конвертировать из моего Seat_Plan_Fragment фрагменту

Так что, если я изменить мой seat_Plan Fragment Расширяет активность, то кнопка деятельность не может быть сделано ...

ответ

0

Если я правильно понял вопрос, то вы можете использовать что-то например, в вашем фрагменте:

((MainActivity) getActivity()).someMethod(); 
Смежные вопросы