Wednesday, January 18, 2012
horizontal gallery view which contains image and texts like profile
//gallery wedgets
private ScrollView nsv;
private HorizontalScrollView sv;
private LinearLayout llh;
private LinearLayout.LayoutParams layoutParamsTV;
private LinearLayout.LayoutParams layoutParamsLL;
private LinearLayout.LayoutParams layoutParamsLLD;
private LinearLayout.LayoutParams layoutParamsTXT;
private LinearLayout.LayoutParams layoutParamsIMG;
private LinearLayout.LayoutParams layoutParamsHOLDER;
private LinearLayout llHoder;
private LinearLayout llFrame;
private LinearLayout lltxts;
private LinearLayout llv;
static int total;
//widgets
ImageView img1;
TextView txt_Name;
TextView txt_Charge;
TextView txt_CatName;
Button b1;
public ListView mListView;
MyAppContext mAppctx;
Call the following method to create gallery and load views
public void horizontalScrollGalleryLayout (List<String> mList3,List<String> mList4,List<String> mList5,List<Service1> mList6) {
Integer[] mThumbIds = {
R.drawable.ds
};
total=0;
Log.i("I got call","for creation of horizontalgallery");
sv = new HorizontalScrollView(this);
llh = new LinearLayout(this);
llh.setOrientation(LinearLayout.HORIZONTAL);
layoutParamsTV = new LinearLayout.LayoutParams(150,190);
layoutParamsTV.setMargins(3, 30, 3, 30);
layoutParamsIMG = new LinearLayout.LayoutParams(60,150);
layoutParamsIMG.setMargins(3, 3, 3, 3);
layoutParamsIMG.height=60;
layoutParamsIMG.width= 60;
layoutParamsTXT = new LinearLayout.LayoutParams(75,150);
layoutParamsTXT.setMargins(3, 3, 3, 3);
layoutParamsLL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsLLD = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
Log.e("in horizantal","scroll view 1");
for(int k=0;k<mList3.size();k++)
{
if(mList3.size()==total)
{
break;
}
llv = new LinearLayout(this);
//llv.setBackgroundColor(R.drawable.border);
for (int i=0; i<2; i++) {
llv.setOrientation(LinearLayout.VERTICAL);
llFrame = new LinearLayout(this);
//llFrame.setPadding(1,1,1,1);
//llFrame.setBackgroundColor(0xFFB0C4DE );
llFrame.setBackgroundResource(R.drawable.layout_border);
lltxts=new LinearLayout(this);
lltxts.setOrientation(LinearLayout.VERTICAL);
llFrame.setOrientation(LinearLayout.HORIZONTAL);
//button=new Button(this);
img1 = new ImageView(this);
txt_Name = new TextView(this);
txt_CatName = new TextView(this);
txt_Charge=new TextView(this);
mCat = new Category();
try {
img1.setImageResource(mThumbIds[0]);
//img1.setTag(mList4.get(total));
img1.setTag(total);
if(!mProfile_pic_url.get(total).equals("null")&&!(mProfile_pic_url.get(total).startsWith(".."))&&(mProfile_pic_url.get(total)!=null)&&!(mProfile_pic_url.get(total).equals("")))
new DownloadImageAsyncTask(mProfileIds.get(total),mAppMgr,img1,"profile_img").execute(mProfile_pic_url.get(total));
txt_Name.setText("Name : "+mList3.get(total));
txt_Name.setTextColor(Color.WHITE);
txt_CatName.setText("Category : "+mAppctx.getCatName());
txt_CatName.setTextColor(Color.WHITE);
txt_Charge.setText("Charge : "+mList6.get(total).service_charge);
txt_Charge.setTextColor(Color.WHITE);
//tx.setPadding(25, 0, 15, 0);
//txt_Name.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
img1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Perform action on click
//CharSequence cat = "Education";
Log.e("TAG","I entered const profile");
Integer id = (Integer) view.getTag();
Log.e("imgTag after clicked",""+ id);
pid=mProfileIds.get(id);
//pid=(CharSequence) img1.getTag();
Log.i("profileid",""+pid);
ArrayList<UserComments> personal_usercomments=new ArrayList<UserComments>();
//UserComments u=new UserComments();
//CharSequence pid = mList2.get(position);
for(int i=0;i<usercomments.size();i++)
{
UserComments u=new UserComments();
Log.i("size is",""+usercomments.size());
if(usercomments.get(i).sp_profileid.equals(pid))
{
//UserComments u=new UserComments();
u.name=usercomments.get(i).name;
u.userComments=usercomments.get(i).userComments;
personal_usercomments.add(u);
}
}
Log.e("pid is ",""+ pid);
ProfileInfo.mCurView=Globals.SENT_FROM_SPLIST;
Intent i1=new Intent(ProfilesList.this,ProfileInfo.class);
i1.putExtra("profileid", pid);
i1.putExtra("rating",mProfileRatings.get(id));
i1.putExtra("profilename",mProfileNames.get(id));
i1.putExtra("service_charge",serviceList.get(id).service_charge);
i1.putExtra("service_id", serviceList.get(id).service_id);
i1.putExtra("profiledes",mProfileDes.get(id));
i1.putParcelableArrayListExtra("comments", personal_usercomments);
i1.putExtra("country", mProfileCountries.get(id));
i1.putExtra("city", mProfileCities.get(id));
i1.putExtra("pic_url",mProfile_pic_url.get(id));
Log.e(TAG,"pic_url"+mProfile_pic_url.get(id));
startActivity(i1);
}
});
//if(total==13)
//break;
//new DownloadImageAsyncTask(mProfileIds.get(total),mAppMgr,img1,"profile_img").execute(Configure.SM_SERVER_URL_PREFIX+(mProfile_pic_url.get(total)));
total++;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
lltxts.addView(txt_Name);
lltxts.addView(txt_CatName);
lltxts.addView(txt_Charge);
llFrame.addView(img1,layoutParamsIMG);
llFrame.addView(lltxts,layoutParamsTXT);
llv.addView(llFrame,layoutParamsTV);
//llv.addView(txt_Name);
//llv.addView(txt_CatName);
//llv.addView(txt_Charge);
if(mList3.size()==total)
break;
//b1[k].setBackgroundResource(mThumbIds[k]);
}
//llv.addView(button, layoutParamsTV);
llh.addView(llv, layoutParamsLL);
llh.setBackgroundColor(Color.TRANSPARENT);
llh.setHorizontalScrollBarEnabled(false);
}
sv.addView(llh, layoutParamsLLD);
//nsv.addView(sv);
sv.setHorizontalScrollBarEnabled(false);
//nsv.setVerticalScrollBarEnabled(false);
setContentView(sv);
//setContentView(nsv);
}
put layoutborder.xml in drawable forlder which puts border.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke android:width="5dp" android:height="5dp"
android:color="#FFC0C0C0" />
<solid android:color="#000000" />
<padding android:left="1dp" android:top="1dp" android:right="1dp"
android:bottom="1dp" />
<corners android:radius="1dp" android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
</item>
</layer-list>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment