1
我有一個圖像,我想創建片段並顯示此圖像,但Line中有錯誤。顯示圖像片段
ImageView.setImageResource(AndroidImageAssete.getmeads.get(0));
這是我的java文件的代碼:
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 the layout for this fragment
ImageView.setImageResource(AndroidImageAssete.getmeads.get(0));
return rootView;
}
}
和主要活動:
BodyPartFragment bodyPartFragment=new BodyPartFragment();
getFragmentManager().beginTransaction()
.add(R.id.contener,contener);
.commit();
}
}
這是錯誤:
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 for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 50.036 secs
Information:2 errors
Information:0 warnings
Information:See complete output in console
什麼是logcat的錯誤替換該行
?在這裏放置logcat錯誤以更好地幫助 –
圖像位於何處?在可繪製的,mipmap或網絡上? – DroiDev
@Droidev在drawable – ahad