O @lucio falou a coisa certa...eu pensava que era "fácil" por isso fui logo implementando pelo exemplo do SDK. Não olhei a documentação mesmo dando erro. E correria kkkkkkk vlw @Buiu, @Andre
Em 25 de agosto de 2013 21:10, Andre Souza <deh.osouza@gmail.com> escreveu:
Verdade! =DEm 25 de agosto de 2013 20:50, Maicon Strey <mstrey@gmail.com> escreveu:
o lucio já deu a solução mas preciso fazer um comentário.Ao invés de colar aqui um código e dizer "tenta esse" seria mais produtivo dizer qual modificação precisa ser feita. Se o novo código funcionar vou precisar comparar o antigo e o novo pra tentar entender o que foi modificado.atenciosamente.--Maicon Strey
Novo Hamburgo - RS - Brasil
------------------------------------Linux user: #525086On Sun, Aug 25, 2013 at 3:20 PM, luciofm <luciofm@gmail.com> wrote:O problema de não ler a documentação e sair fazendo....To use a DrawerLayout, position your primary content view as the first child with a width and height ofmatch_parent. Add drawers as child views after the main content view and set thelayout_gravityappropriately. Drawers commonly usematch_parentfor height with a fixed width.
Primeira view é o Conteúdo, próximas views são Drawers posicionados via layout_gravity.Lúcio Maciel
luciofm@gmail.com2013/8/25 Andre Souza <deh.osouza@gmail.com>Cara isso tá muito confuso.Primeiro: O erro de cast foi pq com certeza vc n colocou o id: android:id="@+id/left_drawer" no linear layout. e tb n mudou em seu codigo.Segundo: Vendo aqui meu codigo oq conclui é: um drawerlayout tem que ter um layout que é digamos a tela principal com o que vc quer que apareça pro usuario e a view que será seu drawer, ou seja a lista com as opções. Agora se vc quer que esse seu drawer seja a lista + fragment vc tem que colocar tudo em um linear layout e colocar o id desse linear layout: android:id="@+id/left_drawer" mas não esquecer de mudar tb no seu codigo.--2013/8/25 Diogo Henrique <diogjp10@gmail.com>Olá Andre, eu fiz como você falou e ficou do mesmo jeito. Apenas a primeira View apareceu. Fiz essa modificação no layout....<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/drawer_layout"android:layout_width="match_parent"android:layout_height="match_parent" ><FrameLayoutandroid:id="@+id/content_frame"android:layout_width="match_parent"android:layout_height="match_parent" /><fragment android:name="br.com.android.noweight.fragment.ProfileFragment"android:id="@+id/profile_fragment"android:layout_gravity="start"android:layout_width="wrap_content"android:layout_height="200dp" /><ListViewandroid:id="@+id/left_drawer"android:layout_width="240dp"android:layout_height="400dp"android:layout_gravity="start"android:layout_below="@id/profile_fragment"android:background="#111"android:choiceMode="singleChoice"android:divider="@android:color/transparent"android:dividerHeight="0dp" /></android.support.v4.widget.DrawerLayout>E apenas a primeira View apareceu, no caso, o Fragment
private DrawerLayout mDrawerLayout;private ListView mDrawerList;private ActionBarDrawerToggle mDrawerToggle;private CharSequence mDrawerTitle;private CharSequence mTitle;private String[] mPlanetTitles;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mTitle = mDrawerTitle = getTitle();mPlanetTitles = getResources().getStringArray(R.array.planets_array);mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);mDrawerList = (ListView) findViewById(R.id.left_drawer);mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,GravityCompat.START);// mDrawerList.setAdapter(new ArrayAdapter<String>(this,// R.layout.drawer_list_item, mPlanetTitles));mDrawerList.setAdapter(new MenuAdapter(this, mPlanetTitles));mDrawerList.setOnItemClickListener(new DrawerItemClickListener());// enable ActionBar app icon to behave as action to toggle nav drawergetSupportActionBar().setDisplayHomeAsUpEnabled(true);getSupportActionBar().setHomeButtonEnabled(true);mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */mDrawerLayout, /* DrawerLayout object */R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */R.string.drawer_open, /* "open drawer" description for accessibility */R.string.drawer_close /* "close drawer" description for accessibility */) {public void onDrawerClosed(View view) {getSupportActionBar().setTitle(mTitle);// invalidateOptionsMenu(); // creates call to// onPrepareOptionsMenu()}public void onDrawerOpened(View drawerView) {getSupportActionBar().setTitle(mDrawerTitle);// invalidateOptionsMenu(); // creates call to// onPrepareOptionsMenu()}};mDrawerLayout.setDrawerListener(mDrawerToggle);if (savedInstanceState == null) {selectItem(0);}}
Se eu colocar um Linear cobrindo tudo, da erro de Cast2013/8/25 Andre Souza <deh.osouza@gmail.com>Acho que o erro pode ta no seu xml. Substitua seu xml por esse:<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><android.support.v4.widget.DrawerLayoutandroid:id="@+id/drawer_layout"android:layout_width="match_parent"android:layout_height="match_parent" ><includeandroid:layout_width="fill_parent"android:layout_gravity="start"android:layout_height="wrap_content"layout="@layout/drawer_profile" /><ListViewandroid:id="@+id/left_drawer"android:layout_width="240dp"android:layout_height="match_parent"android:layout_gravity="start"android:background="#111"android:choiceMode="singleChoice"android:divider="@android:color/transparent"android:dividerHeight="0dp" /></android.support.v4.widget.DrawerLayout></FrameLayout >Ve se aparece tudo como você quer. Se não, veja se colocando o seu include e sua listview dentro de uma linearlayout resolve. E essa linear layout dentro do drawer.--You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
André Luiz de Oliveira Souza
Engenheiro da Computação
Pós-graduando em Desenvolvimento de Software com ênfase em Java CorporativoYou received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
André Luiz de Oliveira Souza
Engenheiro da Computação
Pós-graduando em Desenvolvimento de Software com ênfase em Java Corporativo--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.






0 comentários:
Postar um comentário