android - Display Image in fragment -
i have image , want create fragment , display image there's error in line.
imageview.setimageresource(androidimageassete.getmeads.get(0));
here's code of java file:
public class bodypartfragment extends fragment { public bodypartfragment(){ } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview =inflater.inflate(r.layout.fragment_body_part, container, false); imageview imageview=(imageview) rootview.findviewbyid(r.id.fragment_body_part); // inflate layout fragment imageview.setimageresource(androidimageassete.getmeads.get(0)); return rootview; } } and main activity:
bodypartfragment bodypartfragment=new bodypartfragment(); getfragmentmanager().begintransaction() .add(r.id.contener,contener); .commit(); } } this error:
information:gradle tasks [:app:assembledebug] /users/mac/downloads/flagment/app/src/main/java/com/example/waadalkatheri/flagment/mainactivity.java error:(16, 9) error: illegal start of expression error:execution failed task ':app:compiledebugjavawithjavac'. > compilation failed; see compiler error output details. information:build failed information:total time: 50.036 secs information:2 errors information:0 warnings information:see complete output in console
just replace line
imageview.setimageresource(androidimageassete.getmeads.get(0)); with line
imageview.setimageresource(r.drawable.abc);
Comments
Post a Comment