2016-10-19 6 views
-1

意図を作ろうとするのは、フラグメントから次のアクティビティへと起こります。明らかに、このエラーはgoMakan()で表示されます。 goMakan1(); 。これは私には新しいものであり、それを修正する方法は知られていません。重複する質問があれば申し訳ありません。非静的から静的へ

public static class ViewHolder extends RecyclerView.ViewHolder { 
     public ImageView picture; 
     public TextView name; 
     public TextView description; 

     public ViewHolder(LayoutInflater inflater, ViewGroup parent) { 
      super(inflater.inflate(R.layout.custom_row, parent, false)); 

      picture = (ImageView) itemView.findViewById(R.id.card_image); 
      name = (TextView) itemView.findViewById(R.id.card_title); 
      description = (TextView) itemView.findViewById(R.id.card_text); 

      final Button button[] = new Button[2]; 

      for (int h = 0; h < button.length; h++) { 
       final int b = h; 
       button[h].setOnClickListener(new View.OnClickListener() { 
        @Override 
        public void onClick(View view) { 
         button[0] = (Button) itemView.findViewById(R.id.action_button); 
         button[1] = (Button) itemView.findViewById(R.id.action_button); 
         if (button[b] == button[0]) { 
          goMakan(); 
         } else if (button[b] == button[1]) { 
          goMakan1(); 
         } 
        } 
       }); 
      } 

     } 
    } 



     public void goMakan() { 
     Intent intent = new Intent(getActivity(), Malis.Activity); 
     startActivity(intent); 
    } 
    public void goMakan1(){ 
     Intent intent = new Intent(getActivity(), AbangBurn.Activity); 
     startActivity(intent); 
    } 
+0

このエラー??? –

+0

@PriyeshKumar non-staticを静的コンテキストから参照することはできません –

+0

複製を投稿することについてお詫び申し上げます。代わりに、エラーメッセージのために少なくともGoogleに努力してください。このウェブサイトだけで数千もの重複は見つけられませんでした。 – csmckelvey

答えて

0

静的なものから静的なものを呼び出すことはできません。どちらも静的でなければならない。

前回私はこれに遭遇しましたが、静的メソッドを非静的メソッドとして複製しました。プログラムの別の部分から静的メソッドを静的メソッドにする必要がありました。

関連する問題