Thursday, 18 October 2012

Dynamically load image in activity

package com.example.imagedynamicallyadding;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
       
        LinearLayout layout = new LinearLayout(getApplicationContext());
        LayoutParams parms = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        ImageView img = new ImageView(getApplicationContext());
        img.setPadding(0, 0, 0, 0);
        img.setImageResource(R.drawable.ic_launcher);
        layout.addView(img);
        setContentView(layout);

       
    }

  
}

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...