Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Tentando acessar um ListView que está em um segundo include

Eu usei como base inicial o template "Navigation Drawer Activity" do Android Studio...
E incluí em um dos layouts que compôe a tela a listview

Em terça-feira, 6 de março de 2018 00:37:19 UTC-3, Jilles Ragonha escreveu:
Isso eh para um widget? Se for ele usa remote view. Tem q usar remote view factory no lugar do adapter

On Tue, Mar 6, 2018, 00:35 Shidoshi DF <shido...@gmail.com> wrote:
Pessoal, boa noite.....

Estou tentando resolver um problema de acesso a uma ListView que está em um segundo include. Ou seja, Tenho um layout principal que dentro dele há um include, e dentro deste segundo include está o layout no qual está a listview.

Segue os trechos dos códigos para vocês entenderem melhor...


activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>



app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="br.eti.xxx.xxxxxxx.MainActivity">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimaryDark"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main"
android:id="@+id/includeContentMain"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>



content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="br.eti.mtl.stayclose.MainActivity"
tools:showIn="@layout/app_bar_main">



<LinearLayout
android:id="@+id/ll_listaPessoas"
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="150dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="@color/colorPrimaryDark"
android:layout_alignParentTop="true"
android:layout_above="@+id/ll_botoes_inferiores">

<ListView
android:id="@+id/listViewUserIncomming"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout
</RelativeLayout>



A classe que estou fazendo o inflater já tentei diversas formas, mas sem sucesso

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;

UserStatusDTO userStatusDTO = this.listUserStatusUpcomming.get(position);



//view = activity.getLayoutInflater().inflate(R.layout.activity_geochat_linha_remetente, parent, false);

//https://github.com/codepath/android_guides/wiki/Using-an-ArrayAdapter-with-ListView
// convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_user, parent, false);

//activity.setContentView(R.layout.content_main);
//View v1 = activity.findViewById(R.id.includeContentMain);
//View v2 = v1.findViewById(R.id.ll_listaPessoas);
//View v3 = v2.findViewById(R.id.listViewUserIncomming);
//view = v3.getAc

//view = activity.findViewById(R.id.includeContentMain).findViewById(R.id.ll_listaPessoas).

Activity teste1 = this.activity;
LayoutInflater teste2 = teste1.getLayoutInflater();


view = this.activity.getLayoutInflater().inflate(R.layout.activity_users_list_upcomming, parent, false);

TextView tvUserName = (TextView) view.findViewById(R.id.tvNameUserStatus);
tvUserName.setText(userStatusDTO.getUser().getName());

return view;
}




Bem, será que alguém pode me dar um apoio?????

Obrigado 






.

--
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-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário