2017-09-09 1 views
0

오류를 어디에서 발생했는지 알려주십시오. 조각에서 recycler listview를 구현하고 있습니다.

09-09 13:26:44.132 31899-31899/xxxxxxx.xxxxxxxmessenger E/RecyclerView: No adapter attached; skipping layout 
09-09 13:26:55.725 31899-31899/xxxxxxx.xxxxxxxmessenger E/AndroidRuntime: FATAL EXCEPTION: main 
                      Process: xxxxxxx.xxxxxxxmessenger, PID: 31899 
                      android.content.res.Resources$NotFoundException: Resource ID #0x7f04002b 
                       at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190) 
                       at android.content.res.Resources.loadXmlResourceParser(Resources.java:2101) 
                       at android.content.res.Resources.getLayout(Resources.java:1115) 
                       at android.view.LayoutInflater.inflate(LayoutInflater.java:424) 
                       at freemig.freemigmessenger.adapter.ConnectionsAdapter.onCreateViewHolder(ConnectionsAdapter.java:35) 
                       at xxxxxxx.xxxxxxxmessenger.adapter.ConnectionsAdapter.onCreateViewHolder(ConnectionsAdapter.java:21) 
                       at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6411) 
                       at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5597) 

조각 코드 그래서 recyclerView의

public class All_Connection_fragment extends Fragment { 

    AllConnectionService allConnectionsAPIService; 
    RecyclerView recyclerView; 
    List<ConnectionDatum> connectionData = new ArrayList<>(); 
    ConnectionsAdapter connectionsAdapter; 
    String TimeZone; 

    private SharedPreferences sharedPreferences; 
    private SharedPreferences.Editor editor; 
    private UserAuthenticationKey userAuthenticationKey; 


    public All_Connection_fragment() { 
     // Required empty public constructor 
    } 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

    } 



    @Nullable 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View rootview = inflater.inflate(R.layout.activity_all_connection_fragment, container, false); 

     allConnectionsAPIService = RestClient.getClient().create(AllConnectionService.class); 

     recyclerView = rootview.findViewById(R.id.allConnectionsRecyclerView); 
     recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); 

     connectionsAdapter= new ConnectionsAdapter(connectionData,R.layout.all_connection_list, 
       getActivity().getApplicationContext()); 
       recyclerView.setAdapter(connectionsAdapter); 

     userAuthenticationKey = new UserAuthenticationKey(getActivity()); 
     sharedPreferences = this.getActivity().getSharedPreferences("user authentication", MODE_PRIVATE); 
     editor = sharedPreferences.edit(); 

     TimeZone = "0"; 

     connectionsList(); 


     Thread t = new Thread() { 

      @Override 
      public void run() { 
       try { 
        while (!isInterrupted()) { 
         Thread.sleep(1000); 
         getActivity().runOnUiThread(new Runnable() { 
          @Override 
          public void run() { 
           // update TextView here! 
           connectionsList(); 
          } 
         }); 
        } 
       } catch (InterruptedException e) { 
       } 
      } 
     }; 
     t.start(); 


     return rootview; 
    } 

    private void connectionsList() { 
     final ConnectionRequest connectionRequest = new ConnectionRequest(
       TimeZone.toString(), 
       userAuthenticationKey.getUserId().toString()); 

     Call<ConnectionResponse> call = allConnectionsAPIService.allConnection(userAuthenticationKey.getUserTokenKey(),connectionRequest); 
     call.enqueue(new Callback<ConnectionResponse>() { 
      @Override 
      public void onResponse(Call<ConnectionResponse> call, Response<ConnectionResponse> response) { 
//    Toast.makeText(AllConnectionActivity.this, "" +response.body() , Toast.LENGTH_LONG).show(); 
       connectionData.addAll(response.body().getData()); 
       connectionsAdapter.notifyDataSetChanged(); 
      } 

      @Override 
      public void onFailure(Call<ConnectionResponse> call, Throwable t) { 
       Toast.makeText(getActivity(), "All connection list doesn't response, Please try again", 
         Toast.LENGTH_LONG).show(); 
      } 
     }); 
    } 
} 

어댑터 코드

public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.ConnectionsViewHolder> { 

    private List<ConnectionDatum> connectionData; 
    private int rowLayout; 
    private Context context; 

    public ConnectionsAdapter(List<ConnectionDatum> connectionData, int rowLayout, Context context) { 
     this.connectionData = connectionData; 
     this.rowLayout = rowLayout; 
     this.context = context; 
    } 

    @Override 
    public ConnectionsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.all_connection_list, parent,false); 
     return new ConnectionsViewHolder(view); 
    } 


    @Override 
    public void onBindViewHolder(ConnectionsViewHolder holder, int position) { 

     holder.avater.setTag(connectionData.get(position).getAvatar()); 
     holder.username.setText(connectionData.get(position).getFullName()); 
    } 


    @Override 
    public int getItemCount() { 
     return connectionData.size(); 
    } 


    public class ConnectionsViewHolder extends RecyclerView.ViewHolder { 
     ImageView avater; 
     TextView username; 

     public ConnectionsViewHolder(View itemView) { 
      super(itemView); 

      avater = itemView.findViewById(R.id.avatar); 
      username = itemView.findViewById(R.id.username); 
     } 
    } 
} 
+0

어떻게 당신이 당신의 활동에 조각을 추가하는 XML 파일에서 동일? –

+0

Whats on 줄'ConnectionsAdapter.java : 35'? 또한 당신의 개조를 사용하는 경우 왜 자신의 스레드 – Raghunandan

+0

줄 35 : View view = LayoutInflater.from (parent.getContext()). inflate (R.layout.all_connection_list, parent, false); –

답변

0

당신은 받고 있지 않습니다 참조 : 나는 응용 프로그램을 실행하고 조각 버튼을 누르면이 오류를 받고 있어요 아래 링크를 참조하십시오 :

Android Resources$NotFoundException: Resource ID #0x7f030027

,

또는

점검 "allConnectionsRecyclerView는"이 ID는

+0

나는 이미 해답을 얻었습니다. 의견 확인 –

관련 문제