Skip to content Skip to sidebar Skip to footer

How To Add Dynamic Image With Horizontal Scrollview/listview

I have to develop five to six horizontal scrolling view,in this scrolling image add dynamic using adapter. Feature: 1) Image can be drag and drop one scroll view to another 2) imag

Solution 1:

Solution 2:

Using this code you can add android control programatically to linear layout and just add Horizontal Scrollview to Linear Layout through xml You will get horizontally listview.

//My coding here.
String[] name={"PRASHANT","PRASHANT","PRASHANT","PRASHANT","PRASHANT","PRASHANT","PRASHANT"} ;

myLInearLayoutmain =(LinearLayout) findViewById(R.id.linearLayoutmain);



for(inti=0;i<6;i++)
{
    LinearLayout li=newLinearLayout(getApplicationContext());
    LinearLayout.LayoutParamsparams=newLinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    li.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParamsparams1=newLinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    LinearLayout.LayoutParamsparamsnew=newLinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);


    params1.setMargins(30, 20, 30, 0);
    //add textView
    valueTV = newTextView(this);
    valueTV.setText(""+name[i]);
    valueTV.setId(5);
    valueTV.setLayoutParams(paramsnew);
    valueTV.setGravity(Gravity.CENTER);

    // adding Button to linear
    valueB = newButton(this);
    valueB.setText(""+name[i]);
    valueB.setId(i);
    valueB.setLayoutParams(params);
    valueB.setOnClickListener(this);
    valueB.setGravity(Gravity.CENTER);

    // adding Imageto linear
    img = newImageView(this);
    img.setImageResource(R.drawable.ic_launcher);
    img.setLayoutParams(paramsnew);


    //add the textView and the Button to LinearLayout
    li.addView(valueTV);
    li.addView(valueB);
    li.addView(img);

    li.setLayoutParams(params1);
    myLInearLayoutmain.addView(li);
}

Post a Comment for "How To Add Dynamic Image With Horizontal Scrollview/listview"