Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9152833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:09:03+00:00 2026-06-17T12:09:03+00:00

In my app, I want to do groups of each posts in same post

  • 0

In my app, I want to do groups of each posts in same post category. Listview doesn’t refresh of items counts. Forexample, “.Net” category has 3 posts. Listview has 15 rows. 12 rows are seem empty. How can I refresh listview rows count ? I tried something but I didn’t. Do I create different layout file for every category ? First image shows getting all of posts in my blog. Second image shows getting just posts of “.Net” category.

public class Anasayfa extends FragmentActivity implements ActionBar.TabListener {

    private String[][] liste;
    private int tabdeger = 0; 
    private MyCustomAdapter adapter;

    private static ListView listview;

    /**
     * The serialization (saved instance state) Bundle key representing the
     * current tab position.
     */

    public class arkaPlanIsleri extends  AsyncTask<String[][], String[][], String[][]> {

         private ProgressDialog dialog = new ProgressDialog(Anasayfa.this);
         int kategori;

         public arkaPlanIsleri(int kategori){
             this.kategori = kategori;
         }

         @Override
         protected void onPostExecute(String[][] liste) {
          // TODO Auto-generated method stub
             switch(kategori){
             case 0:

             listview = (ListView)findViewById(R.id.list);
             adapter = new MyCustomAdapter(Anasayfa.this, R.layout.list, liste[0]);
             listview.setAdapter(adapter);


             break;

             case 1:

                 listview = (ListView)findViewById(R.id.list);
                 adapter = new MyCustomAdapter(Anasayfa.this, R.layout.deneme, liste[0]);
                 listview.setAdapter(adapter);

                 break;
             }


          dialog.dismiss();
         }
         @Override
         protected void onPreExecute() {
          // TODO Auto-generated method stub
            dialog.setMessage("Yükleniyor...");

            dialog.show();
         }


        @Override
        protected String[][] doInBackground(String[][]... params) {
            // TODO Auto-generated method stub
            getListFromXml("feed",kategori);
            return liste;
        }
    }

    public class MyCustomAdapter extends ArrayAdapter<String> {

        String[] xmlList;

         public MyCustomAdapter(Context context, int textViewResourceId,
           String[] liste) {
          super(context, textViewResourceId, liste);
          // TODO Auto-generated constructor stub

         xmlList = liste;
         }

         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
          //return super.getView(position, convertView, parent);

          View row=convertView;

          switch(tabdeger){
          case 0:
            if(row==null){
           LayoutInflater inflater=getLayoutInflater();
           row=inflater.inflate(R.layout.list, parent,false);
           } 

            TextView label=(TextView)row.findViewById(R.id.text1);
            label.setText(xmlList[position]);

            ImageView image =(ImageView)row.findViewById(R.id.img);
            image.setImageResource(R.drawable.ic_launcher );
            break;
          case 1:
              if(row==null){
                   LayoutInflater inflater=getLayoutInflater();
                   row=inflater.inflate(R.layout.deneme, parent,false);
                   } 
              TextView label2=(TextView)row.findViewById(R.id.text2);
              label2.setText(xmlList[position]);

              ImageView image2 =(ImageView)row.findViewById(R.id.img2);
              image2.setImageResource(R.drawable.ic_launcher );
              break;
          }

          return row;
         }
        }

    public String[][] getListFromXml(String strng,int kategori)  {

        try {

            URL url=new URL(strng);
            DocumentBuilderFactory dFactory=DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder=dFactory.newDocumentBuilder();

            Document document=dBuilder.parse(new InputSource(url.openStream()));
            document.getDocumentElement().normalize();

            NodeList nodeListCountry=document.getElementsByTagName("item");
            int sayi = nodeListCountry.getLength();
            liste[1] = new String[sayi]; //category
                int genelcount=0;
                int netcount=0;
                int androidcount=0;
                int ilgicount=0;
                int windowscount=0;

            for (int i = 0; i < nodeListCountry.getLength(); i++) {
                Node node=nodeListCountry.item(i);
                Element elementMain=(Element) node;

                NodeList nodeListText=elementMain.getElementsByTagName("title");
                Element elementText=(Element) nodeListText.item(0);

                NodeList kategoriler = elementMain.getElementsByTagName("category");
                Element kategoriText = (Element) kategoriler.item(0);
                liste[1][i] = kategoriText.getChildNodes().item(0).getNodeValue();
                    switch(kategori){
                    case 0:
                        break;
                    case 1:
                        netcount++;
                        break;
                    case 2:
                        androidcount++;
                        break;
                    case 3:
                        genelcount++;
                        break;
                    case 4:
                        ilgicount++;
                        break;
                    case 5:
                        windowscount++;
                        break;
                    }
                }

            switch(kategori){
                case 0:
                    liste[0] = new String[sayi]; //title
                    break;
                case 1:
                    liste[0] = new String[netcount]; //title
                    break;
                case 2:
                    liste[0] = new String[androidcount]; //title
                    break;
                case 3:
                    liste[0] = new String[genelcount]; //title
                    break;
                case 4:
                    liste[0] = new String[ilgicount]; //title
                    break;
                case 5:
                    liste[0] = new String[windowscount]; //title
                    break;
                }
            int flag=0;

            for (int i = 0; i < nodeListCountry.getLength(); i++) {
                Node node=nodeListCountry.item(i);
                Element elementMain=(Element) node;

                NodeList nodeListText=elementMain.getElementsByTagName("title");
                Element elementText=(Element) nodeListText.item(0);

                switch(kategori){
                case 0:
                    liste[0][i]=elementText.getChildNodes().item(0).getNodeValue();
                    break;
                case 1:
                    if(liste[1][i].equals(".Net")){
                        liste[0][flag]=elementText.getChildNodes().item(0).getNodeValue();
                        flag++;
                    }
                    break;
                case 2:
                    if(liste[1][i].equals("Android")){
                        liste[0][flag]=elementText.getChildNodes().item(0).getNodeValue();
                        flag++;
                    }
                    break;
                case 3:
                    if(liste[1][i].equals("Genel")){
                        liste[0][flag]=elementText.getChildNodes().item(0).getNodeValue();
                        flag++;
                    }
                    break;
                case 4:
                    if(liste[1][i].equals("İlgi Çekici")){
                        liste[0][flag]=elementText.getChildNodes().item(0).getNodeValue();
                        flag++;
                    }
                    break;
                case 5:
                    if(liste[1][i].equals("Windows Phone")){
                        liste[0][flag]=elementText.getChildNodes().item(0).getNodeValue();
                        flag++;
                    }
                    break;
                }
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        }catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


        return liste;
    }



@Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_anasayfa);

            liste = new String[2][];

    //       new arkaPlanIsleri(tabdeger).execute();

             listview = (ListView)findViewById(R.id.list);

            // Set up the action bar to show tabs.
            final ActionBar actionBar = getActionBar();
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

            // For each of the sections in the app, add a tab to the action bar.

            actionBar.addTab(actionBar.newTab().setText("HEPSİ")
                    .setTabListener(this));
            actionBar.addTab(actionBar.newTab().setText(".Net")
                    .setTabListener(this));
            actionBar.addTab(actionBar.newTab().setText("ANDROID")
                    .setTabListener(this));
            actionBar.addTab(actionBar.newTab().setText("GENEL")
                    .setTabListener(this));
            actionBar.addTab(actionBar.newTab().setText("İLGİ ÇEKİCİ")
                    .setTabListener(this));
            actionBar.addTab(actionBar.newTab().setText("WINDOWS PHONE")
                    .setTabListener(this));
        }


@Override
    public void onTabSelected(ActionBar.Tab tab,
            FragmentTransaction fragmentTransaction) {
        // When the given tab is selected, show the tab contents in the
        // container view.
        Fragment fragment = new DummySectionFragment();
        Bundle args = new Bundle();
        args.putInt(DummySectionFragment.ARG_SECTION_NUMBER,
                tab.getPosition() + 1);
        fragment.setArguments(args);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, fragment).commit();

        tabdeger = tab.getPosition();
        liste = new String[2][];
//      xmlList = new String[sayi];
        listview.setAdapter(null);
        new arkaPlanIsleri(tabdeger).execute();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:09:05+00:00Added an answer on June 17, 2026 at 12:09 pm

    The Problem is with your XML parser when you get the length of all the Catagories

    liste[1][i] = ((Node) kategoriText).getChildNodes().item(0).getNodeValue();
    
    switch(kategori){
          case 0:
             break;
          case 1:
             netcount++;
             break;
          case 2:
             androidcount++;
             break;
          case 3:
             genelcount++;
             break;
          case 4:
             ilgicount++;
             break;
          case 5:
             windowscount++;
             break;
    }
    

    this will return the same value for everything. you need to test the data coming in. this would work for waht you are trying to do

    liste[1][i] = ((Node) kategoriText).getChildNodes().item(0).getNodeValue();
    
    if (liste[1][i].contains(".Net")){
        netcount++;
    } else if (liste[1][i].contains("Android")){
        androidcount++;
    } .........
    

    ect ect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2000, C# & ASP.net web app. We want to
For example, the users of our app want to search products by entering a
In this app I want that as I click on button the data from
In my app,I want to display some information in the middle of the screen
In my WebView app I want to have a custom onReceivedError screen. Instead I
In my app I want the xml to be created dynamically because depending on
In my app I want to provide bookmarks for text in NSTextView. Should I
I want to use push notification in my app.i want to know that do
In my Rails app I want users to be able to input video links
I want to use session object in my web app.I want to store some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.