How do I create a login and password screen in a Fragment?

Asked

Viewed 404 times

0

I am creating an app for presentation in my school, good as I have only this week to finish the app I need to represent a tracking of a particular bus, so for this I thought of a login screen and password, where in case instead of putting a user, would put the line name and the stop number in the password, when clicking on search would lead me to the demo result in another Activity, just to show how it would work. I created three tools within my app now missing only this to finish, I’m using a Tablayout with three tabs, which in case are fragments. Then I would like someone to give me a light because I have already turned the net and I have not found anything related. I thank you already

Remembering that I’m still beginner in android programming

Here is the code of the part where I want to add the login and password

Java/Package/Screens/screen1

public class tela1 extends Fragment {
    ListView lista;
    ArrayAdapter<String> adapter;

    public static tela1 novaInstancia() {return  new tela1();}
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View tela = inflater.inflate(R.layout.tela1, null);
        return tela;

    }

    @Override
    public String toString(){return "Localizar";}

Java/Mainactivity

public class MainActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener {
    private TabLayout Guias;
    private ViewPager abreTela;
    int atualPosicao=0;

    @Override
    protected void onCreate(Bundle saveInstanceState){
        super.onCreate(saveInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.Ferramenta);
        setSupportActionBar(toolbar);
        //Abre páginas da guia
        abreTela = (ViewPager) findViewById(R.id.Paginas);
        carregaPaginas();
        //Configuração Guia
        Guias = (TabLayout) findViewById(R.id.Guias);
        Guias.setTabGravity(TabLayout.GRAVITY_FILL);
        Guias.setupWithViewPager(abreTela);
        Guias.addOnTabSelectedListener(this);

    }

    //Preencher páginas
    private void carregaPaginas()
    {
        QuadroAdaptador quadro=new QuadroAdaptador(getSupportFragmentManager());
        quadro.addPage(tela1.novaInstancia());
        quadro.addPage(tela2.novaInstancia());
        quadro.addPage(tela3.novaInstancia());
        abreTela.setAdapter(quadro);
    }

    @Override
    public void onTabSelected(TabLayout.Tab tab) {
        abreTela.setCurrentItem(atualPosicao=tab.getPosition());
    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {

    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {

    }

    public void tela3 (View view) {

        Intent intencao = new Intent(this, alvorada.class);
        startActivity(intencao);
    }

    public void tela3maracana (View view) {

        Intent intencao = new Intent(this,maracana.class);
        startActivity(intencao);
    }

    public void tela3res_salvacao (View view) {

        Intent intencao = new Intent(this, res_salvacao.class);
        startActivity(intencao);

    }

    public void telahorariosalvorada (View view){
        Intent intencao = new Intent(this, alvorada_horarios.class);
        startActivity(intencao);

    }
    public void telahorariomaracana (View view){
        Intent intencao = new Intent(this, Maracana_Horarios.class);
        startActivity(intencao);
    }

    public void telahorarioResSalvacao (View view){
        Intent intencao = new Intent(this,ResSalvacao_Horarios.class);
        startActivity(intencao);
    }


}

Layout/tela1.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:id="@+id/onibus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="122dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Ônibus"
        android:textColor="@android:color/darker_gray" />

    <EditText
        android:id="@+id/numerodaparada"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/onibus"
        android:layout_alignStart="@+id/onibus"
        android:layout_below="@+id/onibus"
        android:layout_marginTop="32dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Numero Da Parada"
        android:textColor="@android:color/darker_gray" />

    <Button
        android:id="@+id/buscar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/numerodaparada"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp"
        android:text="Buscar" />
</RelativeLayout>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.