Skip to main content

Posts

Showing posts with the label resource

Android – Bullets in ListView

main.xml : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="10dp"> <ListView android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:listSelector="@android:color/transparent" android:divider="@null"/> </LinearLayout> create a bullet.xml in drawable folder: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <size android:height="6dp" android:width="6dp"/> ...

Fragmentation In Android

See more basics on Android along with interview questions Fragments are a portion of an Activity: Load a fragment Activity to call a fragment : public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } activity_main : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <fragment android:id="@+id/titles" android:layout_width="0px" android:layout_height="match_parent" android:layout_weight="1" class="com.example.googlefragment.TitlesFragment"/> //calls the fragment </LinearLayout> TitlesFragment : ...

Frame by Frame Animation in Android

Call a new xml file which includes the frames that are to be loaded: < ?xml version="1.0" encoding="utf-8"?> < animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android"> < item android:drawable="@drawable/frame_above95_1" android:duration="30"/> < item android:drawable="@drawable/frame_above95_2" android:duration="30"/> < item android:drawable="@drawable/frame_above95_3" android:duration="30"/> < item android:drawable="@drawable/frame_above95_4" android:duration="30"/> < item android:drawable="@drawable/frame_above95_5" android:duration="30"/> < item android:drawable="@drawable/frame_above95_6" android:duration="30"/> < item android:drawable="@drawable/frame_above95_7" android:duration="...

Download an Image from Url and Display it in a ImageView

Bitmap bmImg; ImageView img1; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.sending_card); img1=(ImageView) findViewById(R.id.imageView1); String url="http://i.123g.us/c/efeb_valen_happy/card/107397.gif"; downloadFile(url); } void downloadFile(String fileUrl){ URL myFileUrl =null; try { myFileUrl= new URL(fileUrl); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bmImg = BitmapFactory.decodeStream(is); img1.setImageBitm...