Layout file:
<linearlayout xmlns:android="<a href="http//schemas.android.com/apk/res/android ">http://schemas.android.com/apk/res/android</a> "xmlns:tools="<a href="http//Schemas.android.com/tools ">Http://schemas.android.com/tools</a> "Android:layout_width="match_parent"Android:layout_height="match_parent"android:orientation="Vertical"Tools:context=". Mainactivity"> <ListView android:layout_width="match_parent"Android:layout_height="match_parent"Android:id="@+id/img_txt_list"android:focusable="true"Android:scrollingcache="true"Android:divider="#00000000"Android:scrollbars="None"/></linearlayout><p> </p>
@Override Public boolean isenabled (int// masking The highlight effect of each item of the ListView return False; }
Read the JSON file under assets to simulate network requests:
PublicList<content>Getassetsdata () {Assetmanager am= This. Getassets (); Try{InputStream is=Am.open (path); Bytearrayoutputstream OutputStream=NewBytearrayoutputstream (); byte[] bt =New byte[1024x768]; intLen =0; while(len = is. read (BT))! =-1) {outputstream.write (BT,0, Len); } outputstream.close (); is. Close (); String JSON=outputstream.tostring (); List=analysisjson.getprovincecities (JSON); } Catch(IOException e) {e.printstacktrace (); } returnlist; }
Code: here
Android ListView to implement news client news content Graphics mix