Estou com esse erro de exception, ja fiz de tudo, revi a aula mas nao consigo soluciona-lo.
2021-01-06 14:31:25.092 24295-24295/com.example.agendaalunos E/FragmentManager: No view found for id 0x7f0800af (com.example.agendaalunos:id/frame_principal) for fragment ListaProvasFragment{9687ea7 (24a4ac16-980e-4e60-81ed-a596919683d8) id=0x7f0800af}2021-01-06 14:31:25.092 24295-24295/com.example.agendaalunos E/FragmentManager: Activity state:2021-01-06 14:31:25.134 24295-24295/com.example.agendaalunos E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.example.agendaalunos, PID: 24295java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.agendaalunos/com.example.agendaalunos.ProvasActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f0800af (com.example.agendaalunos:id/frame_principal) for fragment ListaProvasFragment{9687ea7 (24a4ac16-980e-4e60-81ed-a596919683d8) id=0x7f0800af}
package com.example.agendaalunos;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
public class ProvasActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_provas);
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction tx = fragmentManager.beginTransaction();
//substitui quem pelo oque
tx.replace(R.id.frame_principal, new ListaProvasFragment());
//devolve o false ou true
if (getResources().getBoolean(R.bool.modoPaisagem)) {
tx.replace(R.id.frame_secundaria, new DetalhesProvaFragment());
}
tx.commit();
}
}
package com.example.agendaalunos;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import com.example.agendaalunos.modelo.Prova;
import java.util.Arrays;
import java.util.List;
public class ListaProvasFragment extends Fragment {
@RequiresApi(api = Build.VERSION_CODES.M)
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_lista_provas, container, false);
List<String> topicosPort = Arrays.asList("Sujeito","Objeto Direto","Objeto Indireto");
Prova provaPortugues = new Prova("Portugues","04/01/2021",topicosPort);
List<String> topicosMat = Arrays.asList("Trigonometria","Matriz");
Prova provaMatematica = new Prova("Matematica","05/01/2021",topicosMat);
List<Prova> provas = Arrays.asList(provaMatematica, provaPortugues);
ArrayAdapter<Prova> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1,provas);
ListView lista = view.findViewById(R.id.provas_lista);
lista.setAdapter(adapter);
lista.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
// pega o item na posicaçao "i" para mostrar
Prova prova = (Prova) adapterView.getItemAtPosition(i);
Toast.makeText(getContext(),"Clicou na prova " + prova,Toast.LENGTH_LONG).show();
Intent vaiParaDetalhes = new Intent(getContext(),DetalhesProvasActivity.class);
vaiParaDetalhes.putExtra("prova",prova);
startActivity(vaiParaDetalhes);
}
});
return view;
}
}