public void horizontalScrollGalleryLayout (List<String> mList3) {
Integer[] mThumbIds = {
R.drawable.ds
};
Log.i(TAG,"I got call "+"for creation of horizontalgallery");
LinearLayout ll = new LinearLayout(this, null);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setBackgroundColor(Color.WHITE);
LayoutInflater lf = (LayoutInflater)this.getSystemService(this.LAYOUT_INFLATER_SERVICE);
ImageButton srchBtn = (ImageButton)lf.inflate(R.layout.searchbtn, null);
srchBtn.setBackgroundColor(Color.TRANSPARENT);
srchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(CategoryMenu.this,SearchAct.class));
}
});
ll.addView(srchBtn);
setTitle(R.string.search_instructions);
mHorScrlView = new HorizontalScrollView(this);
mLinearlayoutHor = new LinearLayout(this);
mLinearlayoutHor.setOrientation(LinearLayout.HORIZONTAL);
mLinearlayoutHor.setBackgroundColor(color.white);
mLayoutParamsTV = new LinearLayout.LayoutParams(75,75);
mLayoutParamsTV.setMargins(12, 25, 12, 12);
mLayoutParamsLL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
mLayoutParamsLL.setMargins(2,2,2,2);
mLayoutParamsLLD = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
Log.e(TAG,"in horizantal "+"scroll view 1");
for(int k=0;k<mList3.size();k++)
{
if(mList3.size()==mTotal)
{
break;
}
mLinearLayoutVer = new LinearLayout(this);
for (int i=0; i<3; i++) {
mLinearLayoutVer.setOrientation(LinearLayout.VERTICAL);
mLinearLayourFrame = new LinearLayout(this);
mLinearLayourFrame.setBackgroundResource(R.drawable.layout_border1);
mLinearLayourFrame.setOrientation(LinearLayout.VERTICAL);
mImgView = new ImageView(this);
mtxt = new TextView(this);
mCat = new Category();
try {
mImgView.setImageResource(mThumbIds[0]);
mImgView.setTag(mList3.get(mTotal));
mtxt.setText(mList3.get(mTotal));
mtxt.setTextColor(Color.BLUE);
mtxt.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mLinearLayourFrame.addView(mImgView,mLayoutParamsTV);
mLinearLayourFrame.addView(mtxt);
mLinearLayourFrame.setTag(mList3.get(mTotal));
mLinearLayourFrame.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// Perform action on click
CharSequence cat = (CharSequence) view.getTag();
Log.e(TAG,"imgTag after category clicked "+ cat);
CharSequence category = cat;
mCat=mAppMgr.getCategoryObjectFromName(category);
String isleaf = mCat.getIs_leaf();
String parent_id=mCat.getParent_id();
String cat_id=mCat.getCategory_id();
Log.e(TAG,"cat_id : "+cat_id);
String cat_name=mCat.getCategory_name();
Log.e(TAG,"isleaf : "+isleaf);
if(isleaf.equals("false"))
{
Intent i=new Intent(CategoryMenu.this,SubCategoryMenu.class);
Log.d(TAG,"false executed"+"Thanks");
i.putExtra("cat",cat_id);
i.putExtra("cat_name",cat);
i.putExtra("view", Globals.CONST_SUBCATEGORY);
startActivity(i);
}
else
{
Intent i=new Intent(CategoryMenu.this,ProfilesList.class);
Log.d(TAG,"true executed"+"Thanks");
mAppctx.setCatId(cat_id);
mAppctx.setCatName(cat_name);
startActivity(i);
}
Log.e(TAG,"am in"+"sub categories");
}
});
new DownloadImageAsyncTask(mList.get(mTotal),mImgView,"category_img",mTotal).execute(Configure.SM_SERVER_URL_PREFIX+(mCatUrls.get(mTotal)));
mTotal++;
//}
mLinearLayoutVer.addView(mLinearLayourFrame, mLayoutParamsLL);
if(mList3.size()==mTotal)
break;
}
mLinearlayoutHor.addView(mLinearLayoutVer);
mLinearlayoutHor.setBackgroundColor(Color.WHITE);
mLinearlayoutHor.setHorizontalScrollBarEnabled(false);
//mLinearLayourFrame.setClickable(true);
}
mHorScrlView.addView(mLinearlayoutHor, mLayoutParamsLLD);
mHorScrlView.setHorizontalScrollBarEnabled(false);
ll.addView(mHorScrlView);
lf = (LayoutInflater)this.getSystemService(this.LAYOUT_INFLATER_SERVICE);
View convertView = lf.inflate(R.layout.buttons_myaccount, null);
Button myAccntBtn = (Button) convertView.findViewById(R.id.MyAccountBtn);
Button myChatBtn = (Button) convertView.findViewById(R.id.ChatBtn);
myAccntBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Log.e(TAG,"button My Account clicked");
if(CategoryMenu.mStatus){
Log.d(TAG,"am in"+"login status true" );
MyAccount.mCurrentView1=Globals.SENT_FROM_SPLIST;
Intent i=new Intent(CategoryMenu.this,MyAccount.class);
startActivity(i);
}
else
{
LoginInfo.mCurrentView1=Globals.LOGIN_IN_MYACCOUNT;
Intent i=new Intent(CategoryMenu.this,LoginInfo.class);
startActivity(i);
}
}
});
ll.addView(convertView);
setContentView(ll);
}
buttons_myaccount.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="horizontal">
<Button android:id="@+id/MyAccountBtn" android:text="MyAccount"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:textColor="@color/menu_buttons"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:background="@drawable/button_menu"/>
<Button android:id="@+id/ChatBtn" android:text="Chat"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:textColor="@color/menu_buttons"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:background="@drawable/button_menu"/>
<Button android:id="@+id/MoreBtn" android:text="More.."
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:textColor="@color/menu_buttons"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:background="@drawable/button_menu"/>
</LinearLayout>
searchbtn.xml
<?xml version="1.0" encoding="utf-8"?>
<ImageButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/srchbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/searchnew"
android:layout_gravity="left"/>
No comments:
Post a Comment