简体   繁体   English

NullPointerException-JSON,Volley,NetworkImage

[英]NullPointerException - JSON, Volley, NetworkImage

While trying to load the following activity, I ran into a NullPoint exception, I tried resolving the issue but my attempts have been unsuccessful. 尝试加载以下活动时,我遇到了一个N​​ullPoint异常,我尝试解决了该问题,但是我的尝试没有成功。

In brief, there are two activities- one that populates a list of arrays and upon click of an item in the arrays list takes the user to a second activity page (this one) that populate more information about that item. 简而言之,有两个活动:一个活动填充一个数组列表,在单击数组列表中的某个项目时,将带用户到第二个活动页面(该活动页面),该页面填充有关该项目的更多信息。 The first activity load fine with no errors shown, and were the list of array with background image is shown. 第一个活动加载正常,没有显示任何错误,并且显示了带有背景图像的阵列列表。 I receive the unexpected error when an item on the list of arrays is clicked, and hence taking the user to the second activity. 单击数组列表中的某个项目时,我收到意外错误,因此将用户带到第二个活动。

Below is the log cat message: 以下是日志猫消息:

08-29 13:15:32.355: E/AndroidRuntime(1247): FATAL EXCEPTION: main
08-29 13:15:32.355: E/AndroidRuntime(1247): Process: com.dooba.beta, PID: 1247
08-29 13:15:32.355: E/AndroidRuntime(1247): java.lang.NullPointerException
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.volley.Request.<init>(Request.java:130)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.volley.toolbox.ImageRequest.<init>(ImageRequest.java:71)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:220)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:171)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.volley.toolbox.NetworkImageView.loadImageIfNecessary(NetworkImageView.java:140)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.volley.toolbox.NetworkImageView.onLayout(NetworkImageView.java:180)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.View.layout(View.java:14817)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1660)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1436)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.View.layout(View.java:14817)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.HorizontalScrollView.onLayout(HorizontalScrollView.java:1474)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.View.layout(View.java:14817)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.View.layout(View.java:14817)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.View.layout(View.java:14817)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:374)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.View.layout(View.java:14817)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.View.layout(View.java:14817)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.Choreographer.doCallbacks(Choreographer.java:574)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.Choreographer.doFrame(Choreographer.java:544)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.os.Handler.handleCallback(Handler.java:733)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.os.Handler.dispatchMessage(Handler.java:95)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.os.Looper.loop(Looper.java:136)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at android.app.ActivityThread.main(ActivityThread.java:5017)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at java.lang.reflect.Method.invokeNative(Native Method)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at java.lang.reflect.Method.invoke(Method.java:515)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-29 13:15:32.355: E/AndroidRuntime(1247):     at dalvik.system.NativeStart.main(Native Method)

Below is activity code that populates the list of arrays and make reference to the single item activity 下面是活动代码,该代码填充数组列表并引用单个项目活动

public class CasualEventsActivity extends Activity {

    private static final String URL_WEB_SERVICE = "http://dooba.ca/analytics/casual.php";
    private GridView gv;
    private ArrayList<Events_List> container;
     private ArrayList<Events_List> items;
    public Uri list_item_bac;
    public String list_item_name;
    public String list_item_description;
    public String list_item_location;
    public String single_list_item_description;
    public String list_item_price;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.events_list_layout);
        gv = (GridView) findViewById(R.id.gridview);
        container = new ArrayList<Events_List>();
        //download JSON
        listDownload();


        GridView s = (GridView) findViewById(R.id.gridview);
        s.setOnItemClickListener(new OnItemClickListener(){

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(CasualEventsActivity.this,CasualEventsSingleItemActivity.class);

                intent.putExtra("list_item_name", container.get(position).getList_item_title());
                intent.putExtra("list_item_location", container.get(position).getList_item_location());
                intent.putExtra("single_list_item_description", container.get(position).getSingle_list_item_description());
                intent.putExtra("list_item_bac", container.get(position).getList_item_bac());

                startActivity(intent); //start Activity
            }
        });
    }
    public void listDownload(){
        RequestQueue volley = Volley.newRequestQueue(this);
        JsonObjectRequest json = new JsonObjectRequest(Method.GET, URL_WEB_SERVICE, null, ResponseListener(), ErrorListener());
        volley.add(json);
    }

    private Response.Listener<JSONObject> ResponseListener() {
        return new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                try {
                    //your JSON Array
                    JSONArray array = response.getJSONArray("list_item");
                    for(int i = 0; i < array.length(); i++){
                        container.add(convertirAnuncio(array.getJSONObject(i)));
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                gv.setAdapter(new AdapterEvents(getApplicationContext(),container));
                }
            };
        };


    private Response.ErrorListener ErrorListener() {
        return new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) { }
        };
    }

    //object JSON
    private final Events_List convertirAnuncio(JSONObject obj) throws JSONException {
        long id = obj.getLong("id"); //id 
        String list_item_name = obj.getString("list_item_name"); 
        String list_item_location = obj.getString("list_item_location"); 
        String list_item_description = obj.getString("list_item_description");
        String single_list_item_description = obj.getString("single_list_item_description");
        Uri uri = Uri.parse(obj.getString("list_item_bac"));
        return new Events_List(id, list_item_location, single_list_item_description,list_item_name,list_item_description,list_item_price, uri, list_item_bac);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main_activity_actions, menu);
        getActionBar().setDisplayShowTitleEnabled(false);



        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle presses on the action bar items
        switch (item.getItemId()) {
            case R.id.pageExperience:
                openPageExperience();
                return true;
            case R.id.pageMessaging:
                openPageMessage();
                return true;

            case R.id.pageEventsBooking:
                openPageBook();
                return true;

            case R.id.pageProfile:
                openPageProfile();
                return true;

            case R.id.pageReport:
                openPageReport();
                return true;

            case R.id.pageAbout:
                openPageAbout();
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void openPageAbout() {
        // TODO Auto-generated method stub

    }

    private void openPageReport() {
        // TODO Auto-generated method stub

    }

    private void openPageProfile() {
        // TODO Auto-generated method stub
        Intent intent = new Intent(this, ProfileChange.class);
        startActivity(intent);

    }

    private void openPageBook() {
        // TODO Auto-generated method stub

    }

    private void openPageMessage() {
        // TODO Auto-generated method stub

    }

    private void openPageExperience() {
        // TODO Auto-generated method stub
        Intent intent = new Intent(this, MoodActivity.class);
        startActivity(intent);
    }

}

Single item activity code (where the nullpoint error is found) 单项活动代码(在其中找到零点错误)

public class CasualEventsSingleItemActivity extends Activity {

    // Declare Variables
    String list_item_name;
    String list_item_description;
    String list_item_bac;

    String list_item_price;
    String list_item_location;

    String single_list_item_description;




    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_events_single_item);


        ImageLoader mImageLoader = new ImageLoader(Volley.newRequestQueue(this),
                new ImageLoader.ImageCache() {
            private final LruCache<String, Bitmap>
                    cache = new LruCache<String, Bitmap>(20);

            @Override
            public Bitmap getBitmap(String url) {
                return cache.get(url);
            }

            @Override
            public void putBitmap(String url, Bitmap bitmap) {
                cache.put(url, bitmap);
            }
        });


        Intent i = getIntent();
        list_item_name = i.getStringExtra("list_item_name");
        list_item_location = i.getStringExtra("list_item_location");
        list_item_bac = i.getStringExtra("list_item_bac");



        single_list_item_description = i.getStringExtra("single_list_item_description");

        TextView txtname = (TextView) findViewById(R.id.name);
        TextView txtlocation = (TextView) findViewById(R.id.location);
        TextView txtsdescription = (TextView) findViewById(R.id.sdescription);


        NetworkImageView hsvimage1 = (NetworkImageView) findViewById(R.id.hsvimage1);
        NetworkImageView hsvimage2 = (NetworkImageView) findViewById(R.id.hsvimage2);
        NetworkImageView hsvimage3 = (NetworkImageView) findViewById(R.id.hsvimage3);

        // Get image URLs from your previous network request...
        // I could not determine where this is stored from code in your question.
        String url1 = list_item_bac;   // e.g. http://example.com/images/image1.png
        String url2 = list_item_bac;
        String url3 = list_item_bac;

        // Set the URL of the image that should be loaded into this view, and
        // specify the ImageLoader that will be used to make the request.
        hsvimage1.setImageUrl(url1, mImageLoader);
        hsvimage2.setImageUrl(url2, mImageLoader);
        hsvimage3.setImageUrl(url3, mImageLoader);

        // Set results to the TextViews
        txtname.setText(list_item_name);
        txtlocation.setText(list_item_location);
        txtsdescription.setText(single_list_item_description);


        Button mConfirm2 = (Button)findViewById(R.id.bConfirm2);
        mConfirm2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ParseUser currentUser = ParseUser.getCurrentUser();

               // Create the class and the columns
                currentUser.saveInBackground();

                currentUser.put("ActivityName", list_item_name); 
                currentUser.saveInBackground(new SaveCallback() {
                    @Override
                    public void done(ParseException e) {
                        setProgressBarIndeterminateVisibility(false);

                        if (e == null) {
                            // Success!
                            Intent intent = new Intent(CasualEventsSingleItemActivity.this, usermatch.class);
                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                            startActivity(intent);
                        }
                        else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(CasualEventsSingleItemActivity.this);
                            builder.setMessage(e.getMessage())
                                .setTitle(R.string.signup_error_title)
                                .setPositiveButton(android.R.string.ok, null);
                            AlertDialog dialog = builder.create();
                            dialog.show();
                        }
                   }
               });
                //CasualEventsSingleItemActivity.this.startActivity(new Intent(CasualEventsSingleItemActivity.this, MatchingActivity.class));
            }
        });




    }
    }

Layout code 布局代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
        android:background="@drawable/blue_bac3"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="15dp"
         android:layout_marginTop="10dp"

        android:layout_marginRight="15dp"
        android:alpha="0.9"
        android:paddingBottom="3dp"
        android:shadowColor="#000000"
        android:shadowDx="3"
        android:shadowDy="3"
        android:shadowRadius="0.01"
        android:textColor="#82CAFF"
        android:textSize="24sp" />

    <TextView
        android:id="@+id/location"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/name"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:alpha="0.8"
        android:paddingBottom="5dp"
        android:shadowColor="#000000"
        android:shadowDx="3"
        android:shadowDy="3"
        android:shadowRadius="0.01"
        android:textAlignment="center"
        android:textColor="#f2f2f2"
        android:textSize="16sp" />

    <ImageView
        android:id="@+id/dividertop"
        android:layout_width="370dp"
        android:layout_centerHorizontal="true"
        android:layout_height="wrap_content"
        android:layout_below="@+id/location"
        android:alpha="0.6"
        android:background="@drawable/divider11"
        android:paddingBottom="3dp" />

    <ImageView
        android:id="@+id/dividerbottom"
        android:layout_width="370dp"
                android:layout_centerHorizontal="true"

        android:layout_height="wrap_content"
        android:layout_below="@+id/vsvdescription"
       android:alpha="0.6"
        android:background="@drawable/divider11"
        android:paddingBottom="3dp" />

    <ImageView
        android:id="@+id/image_head"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="#000000"
        android:padding="1dp" />

    <HorizontalScrollView
        android:id="@+id/isgallery"
        android:layout_width="370dp"
        android:layout_height="90dp"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/dividerbottom"
        android:layout_marginTop="8dp"
         >

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

               <com.android.volley.toolbox.NetworkImageView
                android:id="@+id/hsvimage1"
                android:layout_width="148dp"
                android:layout_height="90dp"
                android:layout_marginRight="6dp"
                android:layout_alignParentRight="true"
                android:background="#fff"
                android:padding="1dp" />
               <com.android.volley.toolbox.NetworkImageView
                android:id="@+id/hsvimage2"
                android:layout_width="148dp"
                android:layout_height="90dp"
                android:layout_marginRight="6dp"
                android:layout_alignParentRight="true"
                android:background="#000000"
                android:padding="1dp" />
               <com.android.volley.toolbox.NetworkImageView
                android:id="@+id/hsvimage3"
                android:layout_width="148dp"
                android:layout_height="90dp"
                android:layout_marginRight="6dp"
                android:layout_alignParentRight="true"
                android:background="#CCC"
                android:padding="1dp" />
               <com.android.volley.toolbox.NetworkImageView
                android:id="@+id/hsvimage4"
                android:layout_width="148dp"
                android:layout_height="90dp"
                android:layout_alignParentRight="true"
                android:background="#000000"
                android:padding="1dp" />
                        </LinearLayout>

                  </HorizontalScrollView>

    <Button
        android:id="@+id/bConfirm2"
        android:layout_width="90dp"
        android:layout_height="50dp"
        android:layout_below="@+id/isgallery"
        android:layout_centerHorizontal="true"
        android:alpha="0.7"
        android:layout_marginTop="10dp"
        android:background="@drawable/gray_bac"
        android:text="Confirm"
        android:textColor="#2B3856"
        android:textStyle="bold" />

     <ScrollView
        android:id="@+id/vsvdescription"
        android:layout_width="370dp"
        android:layout_height="250dp"
        android:layout_marginTop="7dp"
        android:layout_marginBottom="7dp" 
        android:padding="5dp"       

        android:layout_centerHorizontal="true"
        android:layout_below="@+id/dividertop"
         >

            <RelativeLayout
                android:orientation="vertical"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/sdescription"
        android:layout_width="370dp"
        android:layout_height="250dp"
        android:gravity="center"
        android:alpha="0.65"
        android:textColor="#ffffff"
        android:textSize="18sp" />

    </RelativeLayout>
    </ScrollView>

</RelativeLayout>

Thanks in advance, and if you need any clarification, let me know. 预先感谢您,如果您需要任何澄清,请告诉我。 All the best, 祝一切顺利,

Update 2 更新2

In the activity that populates the list of arrays, the item being populated on the single item activity (after user has click on an item) is referred to as 在填充数组列表的活动中,在单个项目活动中填充的项目(在用户单击某个项目之后)称为

@Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(CasualEventsActivity.this,CasualEventsSingleItemActivity.class);

            intent.putExtra("list_item_name", container.get(position).getList_item_title());
            intent.putExtra("list_item_location", container.get(position).getList_item_location());
            intent.putExtra("single_list_item_description", container.get(position).getSingle_list_item_description());
            intent.putExtra("list_item_bac", container.get(position).getList_item_bac());
            startActivity(intent); //start Activity
        }

The get item reference is refered in another activity 获取项目引用在另一个活动中被引用

public class Events_List {
public long id;
public String list_item_title;
public String list_item_location;
public String list_item_price;
public Uri single_list_item_bac;
public Uri list_item_bac;

public String list_item_description;
public String single_list_item_description;

public Uri url;

public Events_List(long id, String list_item_location, String single_list_item_description, String list_item_title, String list_item_description, String list_item_price, Uri url, Uri list_item_bac){
    this.id = id;
    this.list_item_title = list_item_title;
    this.list_item_location = list_item_location;
    this.list_item_description = list_item_description;
    this.single_list_item_description = single_list_item_description;
    this.list_item_price = list_item_price;
    this.list_item_bac = list_item_bac;
    this.url = url;
}

public String getList_item_title()
{
    return this.list_item_title;
}

public String getList_item_bac()
{
    return this.list_item_title;
}

public String getList_item_location()
{
    return this.list_item_location;
}

public String getList_item_price()
{
    return this.list_item_price;
}

public String getList_item_description()
{
    return this.list_item_description;
}

public String getSingle_list_item_description()
{
    return this.single_list_item_description;
}


}

Update 3: 更新3:

08-31 12:20:33.153: E/AndroidRuntime(1271): FATAL EXCEPTION: main
08-31 12:20:33.153: E/AndroidRuntime(1271): Process: com.dooba.beta, PID: 1271
08-31 12:20:33.153: E/AndroidRuntime(1271): java.lang.NullPointerException
08-31 12:20:33.153: E/AndroidRuntime(1271):     at com.dooba.beta.Events_List.getList_item_bac(Events_List.java:36)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at com.dooba.beta.CasualEventsActivity$1.onItemClick(CasualEventsActivity.java:71)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.widget.AdapterView.performItemClick(AdapterView.java:299)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2904)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.widget.AbsListView$3.run(AbsListView.java:3638)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.os.Handler.handleCallback(Handler.java:733)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.os.Handler.dispatchMessage(Handler.java:95)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.os.Looper.loop(Looper.java:136)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at android.app.ActivityThread.main(ActivityThread.java:5017)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at java.lang.reflect.Method.invokeNative(Native Method)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at java.lang.reflect.Method.invoke(Method.java:515)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-31 12:20:33.153: E/AndroidRuntime(1271):     at dalvik.system.NativeStart.main(Native Method)

change 更改

public String getList_item_bac()
{
    return this.list_item_bac.toString();
}

to

public Uri getList_item_bac()
{
    return this.list_item_bac;
}

also i have changed this 我也改变了这个

   private final Events_List convertirAnuncio(JSONObject obj) throws JSONException {
    long id = obj.getLong("id"); //id 
    String list_item_name = obj.getString("list_item_name"); 
    String list_item_location = obj.getString("list_item_location"); 
    String list_item_description = obj.getString("list_item_description");
    String single_list_item_description = obj.getString("single_list_item_description");
    String list_item_price = obj.getString("list_item_price");
    Uri uri = Uri.parse(obj.getString("list_item_bac"));
    return new Events_List(id, list_item_location, single_list_item_description,list_item_name,list_item_description,list_item_price, uri, uri);
}

and change 并改变

intent.putExtra("list_item_bac", container.get(position).getList_item_bac());

to

intent.putExtra("list_item_bac", container.get(position).getList_item_bac().toString());

so you will get: 这样您将获得:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM