0

Dont get display data in listview.i got parser list success fully but integration with costume adapter of listview get frustration.I Dont think that problem in parser it get success in logcat but now lazy load and display problem are raise.

Error:

 11-02 12:10:58.470: WARN/PackageManager(613): Failure retrieving icon 0x7f020000 in package com.SAXParser1
11-02 12:10:58.470: WARN/PackageManager(613): android.content.res.Resources$NotFoundException: Resource ID #0x7f020000
11-02 12:10:58.470: WARN/PackageManager(613):     at android.content.res.Resources.getValue(Resources.java:846)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.content.res.Resources.getDrawable(Resources.java:534)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.app.ApplicationContext$ApplicationPackageManager.getDrawable(ApplicationContext.java:1923)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.content.pm.ComponentInfo.loadIcon(ComponentInfo.java:88)
11-02 12:10:58.470: WARN/PackageManager(613):     at com.android.launcher.LauncherModel.updateApplicationInfoTitleAndIcon(LauncherModel.java:452)
11-02 12:10:58.470: WARN/PackageManager(613):     at com.android.launcher.LauncherModel.updateAndCacheApplicationInfo(LauncherModel.java:257)
11-02 12:10:58.470: WARN/PackageManager(613):     at com.android.launcher.LauncherModel.updatePackage(LauncherModel.java:242)
11-02 12:10:58.470: WARN/PackageManager(613):     at com.android.launcher.Launcher$ApplicationsIntentReceiver.onReceive(Launcher.java:1865)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:664)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.os.Handler.handleCallback(Handler.java:587)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.os.Looper.loop(Looper.java:123)
11-02 12:10:58.470: WARN/PackageManager(613):     at android.app.ActivityThread.main(ActivityThread.java:3948)
11-02 12:10:58.470: WARN/PackageManager(613):     at java.lang.reflect.Method.invokeNative(Native Method)
11-02 12:10:58.470: WARN/PackageManager(613):     at java.lang.reflect.Method.invoke(Method.java:521)
11-02 12:10:58.470: WARN/PackageManager(613):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
11-02 12:10:58.470: WARN/PackageManager(613):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
11-02 12:10:58.470: WARN/PackageManager(613):     at dalvik.system.NativeStart.main(Native Method)

Code ::

package com.SAXParser1;

import java.net.URL;
import java.util.ArrayList;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class SAXParser1 extends Activity implements OnItemClickListener {
    /** Called when the activity is first created. */
    String RequestID;
    String Status;
    String URL1;
    String ActivityName;
    String AudioScript;
    ListView lview;

    String[] Arr_RequestID;
    String[] Arr_Status;
    String[] Arr_ActivityName;
    String[] Arr_AudioScript;

    ArrayList<String> al_RequestID;
    ArrayList<String> al_Status;
    ArrayList<String> al_ActivityName;
    ArrayList<String> al_AudioScript;

    ListViewAdapter lviewAdapter;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String url = "URL";
        SaxParser(url);
        try {
            lview = (ListView) findViewById(R.id.listView2);
            lviewAdapter = new ListViewAdapter(this, Arr_ActivityName,
                    Arr_AudioScript);

            System.out.println("adapter => " + lviewAdapter.getCount());

            lview.setAdapter(lviewAdapter);

            lview.setOnItemClickListener(this);
        } catch (Exception e) {
            // TODO: handle exception
        }

    }

    public void onItemClick(AdapterView<?> arg0, View arg1, int position,
            long id) {

    }

    public void SaxParser(String url) {

        try {

            URL sourceUrl = new URL(url);

            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            Handler1 dataHandler = new Handler1();
            xr.setContentHandler(dataHandler);
            xr.parse(new InputSource(sourceUrl.openStream()));
            Dataset dataset = dataHandler.getParsednewJobdtl_DataSet();
            Toast.makeText(getBaseContext(), "sourceUrl" + sourceUrl,
                    Toast.LENGTH_LONG);

            RequestID = dataset.getRequestID();
            /*System.out.println(RequestID);*/
            al_ActivityName = dataHandler.getActivityName();
            al_AudioScript = dataHandler.getAudioScript();
            al_RequestID = dataHandler.getRequestId();
            al_Status = dataHandler.getStatus();


            Arr_ActivityName = al_ActivityName
                    .toArray(new String[al_ActivityName.size()]);
            Arr_AudioScript = al_AudioScript.toArray(new String[al_AudioScript
                    .size()]);
            Arr_RequestID = al_RequestID
                    .toArray(new String[al_RequestID.size()]);
            Arr_Status = al_Status.toArray(new String[al_Status.size()]);

            Toast.makeText(getBaseContext(), "al_Status " + al_RequestID,
                    Toast.LENGTH_LONG);
            Status = dataset.getStatus();
            Toast.makeText(getBaseContext(), "al_Status " + al_Status,
                    Toast.LENGTH_LONG);
            ActivityName = dataset.getActivityName();
            Toast.makeText(getBaseContext(), "al_ActivityName " + al_ActivityName,
                    Toast.LENGTH_LONG);
            AudioScript = dataset.getAudioScript();
            Toast.makeText(getBaseContext(), "al_AudioScript " + al_AudioScript,
                    Toast.LENGTH_LONG);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

ListViewAdapter::

package com.SAXParser1;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListViewAdapter extends BaseAdapter {
    Activity context;
    String title[];
    String description[];

    public ListViewAdapter(Activity context, String[] title,
            String[] description) {
        super();
        this.context = context;
        this.title = title;
        this.description = description;
    }

    public int getCount() {
        // TODO Auto-generated method stub
        return title.length;
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    private class ViewHolder {
        TextView txtViewTitle;
        TextView txtViewDescription;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ViewHolder holder;
        LayoutInflater inflater = context.getLayoutInflater();

        if (convertView == null) {
            convertView = inflater.inflate(R.layout.listitem_row, null);
            holder = new ViewHolder();
            holder.txtViewTitle = (TextView) convertView
                    .findViewById(R.id.textView1);
            holder.txtViewDescription = (TextView) convertView
                    .findViewById(R.id.textView2);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.txtViewTitle.setText(title[position]);
        holder.txtViewDescription.setText(description[position]);

        return convertView;
    }

}
user
  • 86,916
  • 18
  • 197
  • 190
Nikunj Patel
  • 21,853
  • 23
  • 89
  • 133

3 Answers3

4

Simple demo of lazy list with images. May be helpful to somebody. It downloads images in the background thread. Images are being cached on SD card and in memory. I create just one thread and place download tasks into the queue. I think that's much more effective than multiple threads downloading and decoding images simultaneously. The cache implementation is very simple just enough for the demo. I decode images with inSampleSize to reduce memory consumption. I also try to handle recycled views correctly.

GitHub: https://github.com/thest1/LazyList

Source: http://open-pim.com/tmp/LazyList.zip

3

Clean the project using project->clean and make sure you have checked "Build Automatically" in project menu.

FYI, just check Resources.NotFoundException,there is clearly written that this exception raises whenever the request resource doesn't found so its better that you check the icon that you have to tried to use inside your code. If you don't find the id of the same icon in R.java file then re-generate the R.java by above way.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • i have clean it but not get any single effect – Nikunj Patel Nov 02 '11 at 06:53
  • and yes build automatically option are check at android installation time. – Nikunj Patel Nov 02 '11 at 06:54
  • have you tried uninstalling old and do re-installation again? – Paresh Mayani Nov 02 '11 at 06:59
  • @Dr.nik Try Closing everything and restart emulator and eclipse and Clean and Build the project.That's the Problem Can be Solved if you are sure that you have that resource in R file and still having the problem..then this is the only way i think – MKJParekh Nov 02 '11 at 07:00
  • Also, right click on the Project and in package explorer, go to Configure build path. In Java build path -> Source tab, remove the App/gen folder and Build the app clean. – Vinay Nov 02 '11 at 07:02
  • 1
    open your R.java in gen folder. Look what is the image name the resource is pointing to.. See if the file icon file is present in drawable folder – Vinay Nov 02 '11 at 07:04
  • @PareshMayani at per vijay comment i have remove folder from build are now it raise more complication so how can i get back? – Nikunj Patel Nov 02 '11 at 07:16
  • [2011-11-02 12:44:55 - SAXParser1] /SAXParser1/gen already exists but is not a source folder. Convert to a source folder or rename it. – Nikunj Patel Nov 02 '11 at 07:20
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/4655/discussion-between-vinay-and-dr-nik) – Vinay Nov 02 '11 at 07:59
2

To avoid confusion, it might help if you followed normal Java naming conventions - this is just a suggestion, but your package name com.SAXParser1 for one is rather non-standard (starts with and includes capital letters, uses just com rather than your full domain), but what's more, it has the same name as your class, which can lead to confusion (at least it confused me trying to read your code... ;-).

The stack trace you posted seems to indicate that Android is expecting a resource with id 0x7f020000, i.e. a line like this:

public static final int <some_name>=0x7f020000

in your R file (somewhere within public static final class drawable). Try opening that file (Ctrl+Shift+T, then type "com.SAXParser1.R") and do a text search for 0x7f020000. If your R file is corrupt, try right-clicking on the project and going "Android Tools" -> "Fix Project Properties".

Edit: have a look at this post for some other suggestions. It might also help if you ensured your files and Eclipse are in sync by right-clicking on the project and selecting Refresh (not necessary in Indigo, I believe, but always a gotcha in Helios and below).

Community
  • 1
  • 1
Amos M. Carpenter
  • 4,848
  • 4
  • 42
  • 72