How to change/update a item from a Drawer layout?

user5450074

This is where i put my items inside the DrawerList and view

tagTitles = getResources().getStringArray(R.array.Tags);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerList = (ListView) findViewById(R.id.left_drawer);
    items = new ArrayList<DrawerItem>();
    items.add(new DrawerItem(tagTitles[0], R.drawable.slider2));
    items.add(new DrawerItem(tagTitles[1], R.drawable.empty));

    items.add(new DrawerItem( String.format(getResources().getString(R.string.levelshow),nBases), R.drawable.empty));
    drawerList.setAdapter(new DrawerListAdapter(this, items));
    drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
                case 0://more for here

This is the Drawer item

public class DrawerItem {
private String name;
private int iconId;

public DrawerItem(String name, int iconId) {
    this.name = name;
    this.iconId = iconId;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public int getIconId() {
    return iconId;
}

public void setIconId(int iconId) {
    this.iconId = iconId;
}
}

DrawerListAdapter

public DrawerListAdapter(Context context, List objets) {
    super(context, 0, objets);
}

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

    if (convertView == null) {

        LayoutInflater inflater = (LayoutInflater) parent.getContext().
                getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.list, null);

    }




    ImageView icon = (ImageView) convertView.findViewById(R.id.list_pngg);
    TextView name = (TextView) convertView.findViewById(R.id.list_itemm);
    //FrameLayout foter = (FrameLayout) convertView.findViewById(R.id.fot);
    boolean footer;
    DrawerItem item = (DrawerItem) getItem(position);
    Log.d("help", String.valueOf(name));
    name.setText(item.getName());

    icon.setImageResource(item.getIconId());

the case is that i want to modificate a Text from the last item, as you can see the item have a string.xml text for that item with a place holder, i need that string to be update when i want. and i do not find the proper way to do this, please help

edit:Pertinent part of XML //lots of views for here android:layout_alignParentBottom="true">

    </RelativeLayout>

</LinearLayout>


<ListView
    android:id="@+id/left_drawer"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"

    android:divider="#4a4a4a"
    android:dividerHeight="0.56dp"
    android:background="#111"
    android:footerDividersEnabled="false"
    android:drawSelectorOnTop="false"
    android:headerDividersEnabled="false"

    android:stackFromBottom="false"

     />

Maciej Sikora

View is updating only when You fire notifyDataSetChanged() in adapter.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to close navigation drawer when an item is pressed from it?

From Dev

How to disable drawer layout from one side?

From Dev

How to close Drawer layout on BackPress in Android?

From Dev

how to add a navigation drawer in an existing layout

From Dev

How to add an image header in navigation drawer layout

From Dev

How to show my layout below the navigation drawer?

From Dev

How to get view from drawer header layout with binding in activity?

From Dev

How to pass data to navigation drawer item?

From Dev

How to set text to view from drawer header layout in navigation drawer without inflating view

From Dev

How to disable or hide a Drawer Layout from Fragment Android

From Dev

Navigation drawer: How to know the current selected item?

From Dev

How to add subtitle to material drawer layout?

From Dev

How to extend the view out of drawer layout?

From Dev

How to add a view above drawer layout?

From Dev

How to disable drawer layout from one side?

From Dev

how to keep a layout scaled inside navigation drawer

From Dev

android how to create a drawer layout in right of screen

From Dev

no more allow open Drawer layout from right side in navigation drawer

From Dev

How to generate Navigation Drawer item's dynamically from xml?

From Dev

item's color in drawer_layout in android studio

From Dev

How to select item navigation drawer from fragment

From Dev

How to open next drawer on click of a specific fragment of previous drawer item

From Dev

How to change/update a item from a Drawer layout?

From Dev

How to add subtitle to material drawer layout?

From Dev

How to start Drawer Layout below the toolbar in Android?

From Dev

How to avoid an item's layout changes from repeating in a RecyclerView?

From Dev

How to change setting icon in Navigation Drawer Layout?

From Dev

How to center a custom layout in navigation drawer?

From Dev

Change layout from the drawer activity example

Related Related

  1. 1

    How to close navigation drawer when an item is pressed from it?

  2. 2

    How to disable drawer layout from one side?

  3. 3

    How to close Drawer layout on BackPress in Android?

  4. 4

    how to add a navigation drawer in an existing layout

  5. 5

    How to add an image header in navigation drawer layout

  6. 6

    How to show my layout below the navigation drawer?

  7. 7

    How to get view from drawer header layout with binding in activity?

  8. 8

    How to pass data to navigation drawer item?

  9. 9

    How to set text to view from drawer header layout in navigation drawer without inflating view

  10. 10

    How to disable or hide a Drawer Layout from Fragment Android

  11. 11

    Navigation drawer: How to know the current selected item?

  12. 12

    How to add subtitle to material drawer layout?

  13. 13

    How to extend the view out of drawer layout?

  14. 14

    How to add a view above drawer layout?

  15. 15

    How to disable drawer layout from one side?

  16. 16

    how to keep a layout scaled inside navigation drawer

  17. 17

    android how to create a drawer layout in right of screen

  18. 18

    no more allow open Drawer layout from right side in navigation drawer

  19. 19

    How to generate Navigation Drawer item's dynamically from xml?

  20. 20

    item's color in drawer_layout in android studio

  21. 21

    How to select item navigation drawer from fragment

  22. 22

    How to open next drawer on click of a specific fragment of previous drawer item

  23. 23

    How to change/update a item from a Drawer layout?

  24. 24

    How to add subtitle to material drawer layout?

  25. 25

    How to start Drawer Layout below the toolbar in Android?

  26. 26

    How to avoid an item's layout changes from repeating in a RecyclerView?

  27. 27

    How to change setting icon in Navigation Drawer Layout?

  28. 28

    How to center a custom layout in navigation drawer?

  29. 29

    Change layout from the drawer activity example

HotTag

Archive