HorizontalScrollView in ViewPager - android

I'm new to Android. I need to implement a horizontalScrollView half screen in ViewPager. The viewPager works well, it swipes. I have inserted the horizontalscrollview in detail_fragement.xml but it does not scroll.. Please find my code below and help me.
Detail.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="15dip"
android:layout_alignParentBottom="true"
android:background="#cc0031" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/small_marker" />
<TextView
android:id="#+id/txt_store_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="#color/white"
android:textSize="10dp"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="#+id/linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/burger_wraps"
android:orientation="vertical" >
<Button
android:id="#+id/btn_back"
android:layout_width="44dp"
android:layout_height="wrap_content"
android:alpha="0"
android:text="" />
<Button
android:id="#+id/btn_detail_back"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:alpha="0.0"
android:text="" />
<Button
android:id="#+id/btn_detail_basket"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/btn_map_back"
android:layout_alignBottom="#+id/btn_map_back"
android:layout_alignParentRight="true"
android:alpha="0"
android:text="" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/footer"
android:layout_below="#+id/linear"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
DetailActivity.java
public class DetailActivity extends FragmentActivity{
RSSFeed feed;
int pos;
private DescAdapter adapter;
private ViewPager pager;
HorizontalScrollView hori;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail);
// Get the feed object and the position from the Intent
feed = (RSSFeed) getIntent().getExtras().get("feed");
pos = getIntent().getExtras().getInt("pos");
// Initialize the views
adapter = new DescAdapter(getSupportFragmentManager());
pager = (ViewPager) findViewById(R.id.pager);
// Set Adapter to pager:
pager.setAdapter(adapter);
pager.setCurrentItem(pos);
hori = (HorizontalScrollView) findViewById(R.id.horizontalScrollView1);
}
public class DescAdapter extends FragmentStatePagerAdapter {
public DescAdapter(FragmentManager fm) {
super(fm);
}
#Override
public int getCount() {
return feed.getItemCount();
}
#Override
public Fragment getItem(int position) {
DetailFragment frag = new DetailFragment();
Bundle bundle = new Bundle();
bundle.putSerializable("feed", feed);
bundle.putInt("pos", position);
frag.setArguments(bundle);
return frag;
}
}
}
detail_fragement.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical" >
<TextView
android:id="#+id/title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/image"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text=""
android:textColor="#color/grey"
android:textSize="20dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/image"
android:layout_width="170dp"
android:layout_height="170dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/grilled" />
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/title1"
android:layout_marginTop="60dp"
android:background="#color/grey" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/title1"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:src="#drawable/tag_price" />
<TextView
android:id="#+id/txt_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView1"
android:layout_centerHorizontal="true"
android:paddingTop="5dp"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="bold" />
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/view1" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="31dp"
android:layout_marginTop="53dp"
android:src="#drawable/image" />
</HorizontalScrollView>
DetailFragement.java
public class DetailFragment extends Fragment {
private int fPos;
RSSFeed fFeed;
ImageLoader imageLoader;
String Name, Price, Image_det;
HorizontalScrollView ScrollView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fFeed = (RSSFeed) getArguments().getSerializable("feed");
fPos = getArguments().getInt("pos");
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater
.inflate(R.layout.detail_fragment, container, false);
// Initializr views
TextView title = (TextView) view.findViewById(R.id.title1);
Image = (ImageView) view.findViewById(R.id.image);
TextView price = (TextView) view.findViewById(R.id.txt_price);
Name = fFeed.getItem(fPos).getTitle();
Price = fFeed.getItem(fPos).getPrice();
// Set the views
title.setText(fFeed.getItem(fPos).getTitle());
price.setText(fFeed.getItem(fPos).getPrice());
imageLoader = new ImageLoader(getActivity().getApplicationContext());
imageLoader.DisplayImage(fFeed.getItem(fPos).getImage(), Image);
ScrollView= (HorizontalScrollView) view.findViewById(R.id.horizontalScrollView1);
//ScrollView.setAdapter(adapter);
ScrollView.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
ScrollView.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
return view;
}

Related

grid view items not scrolling down to up (repeating the items) and when i am loading data from server in android?

I have a grid view and data updated in grid view using api calls and grid item loads a image from url using picasso library all are perfect but when i am scrolling down to up the grid items not scrolled and repeating the items(up to down scrolling was perfect).
Adapterclass.java
private class ProductAdapter extends BaseAdapter {
ViewHolder holder = null;
#Override
public int getCount() {
return mProducts != null ? mProducts.size() : 0;
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
holder = new ViewHolder();
if (convertView == null) {
// convertView = LayoutInflater.from(Products_activity.this).inflate(R.layout.product_layout, null, false);
LayoutInflater vi = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.product_layout, null);
holder.product_name = (TextView) convertView.findViewById(R.id.product_name);
holder.product_descr = (TextView) convertView.findViewById(R.id.product_desc);
holder.product_price = (TextView) convertView.findViewById(R.id.product_price);
holder.product_pic = (ImageView) convertView.findViewById(R.id.iv_division_img);
holder.product_share = (ImageView) convertView.findViewById(R.id.productshare_button);
holder.like_image=(ImageView) convertView.findViewById(R.id.like_image);
convertView.setTag(holder);
}else{
holder = (ViewHolder)convertView.getTag();
}
if (mProducts != null) {
String url = "http://staggershop.pivalue.net/assets/product_images/"+mProducts.get(position).product_image;
String urls = url.replaceAll(" ", "%20");
Picasso.with(getApplicationContext()).load(urls).resize(300,300).noFade().error(R.drawable.home_brands).into(holder.product_pic);
holder.product_name.setText(mProducts.get(position).product_name);
//product_descr.setText(mProducts.get(position).pr);
// product_price.setText(mProducts.get(position).product_price);
/* Picasso
.with(getApplicationContext())
.setLoggingEnabled(true);
Picasso.with(getApplicationContext())
.load(urls)
.error(R.drawable.home_brands).memoryPolicy(MemoryPolicy.NO_STORE)
.networkPolicy(NetworkPolicy.NO_STORE)
.into(product_pic);*/
holder.product_descr.setText(mProducts.get(position).product_description);
if(!recently_beans.isEmpty()){
for(int i=0;i<recently_beans.size();i++) {
if (mProducts.get(position).prdid.equals(recently_beans.get(i).prod_id))
{
holder.like_image.setImageResource(R.drawable.like);
}
}
notifyDataSetChanged();
}
}
holder.product_share.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
}
});
holder.like_image.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
if (!recently_beans.isEmpty()) {
for (int i = 0; i < recently_beans.size(); i++) {
if (mProducts.get(position).prdid.equals(recently_beans.get(i).prod_id)) {
holder.like_image.setImageResource(R.drawable.dislike);
Inserfavorite(mProducts.get(position).prdid);
}
}
}
}
});
}
});
// notifyDataSetChanged();
convertView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Inserrecent(mProducts.get(position).prdid);
Intent intent = new Intent(Products_activity.this, Product_description.class);
startActivity(intent);
}
});
return convertView;
}
}
public static class ViewHolder {
public TextView product_name;
public TextView product_descr;
public TextView product_price;
public ImageView product_pic ;
public ImageView product_share;
public ImageView like_image;
}
This my product.xml
<RelativeLayout
android:id="#+id/rl_divisioin_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/product_img">
<ImageView
android:id="#+id/iv_division_img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/view"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:src="#drawable/home_brands" />
</LinearLayout>
<LinearLayout
android:id="#+id/prod_name_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#+id/product_img"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:elevation="4dp"
android:fontFamily="#string/font_family_regular"
android:gravity="center"
android:padding="5dp"
android:maxLines="1"
android:text="product name"
android:textColor="#color/black"
android:textSize="10sp" />
<TextView
android:id="#+id/product_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:elevation="4dp"
android:fontFamily="#string/font_family_regular"
android:gravity="center"
android:maxLines="1"
android:padding="5dp"
android:text="product Description"
android:textColor="#color/black"
android:textSize="10sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/product_desc"
android:layout_gravity="center"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:elevation="4dp"
android:text="100$"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/productshare_button"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:elevation="4dp"
android:layout_marginRight="5dp"
android:src="#mipmap/symbol_dotss"
android:text="product name"
android:textColor="#color/black"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_margin="5dp"
android:id="#+id/like_image"
android:layout_alignParentEnd="true"
android:src="#drawable/dislike" />
</RelativeLayout>
activty_product.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/coordinator"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/rltool"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/toolbar1"
android:background="#color/textColorPrimary"
app:titleTextColor="#color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/AppTheme.Toolbar"
app:layout_scrollFlags="scroll|enterAlways">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/search1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#drawable/background_shape_buttons">
<!-- <EditText
android:id="#+id/searchEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#D6D5C0"
android:hint="Search..................."
android:layout_gravity="center"
android:backgroundTint="#00000000" />-->
<SearchView
android:id="#+id/search"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:textColorHint="#D6D5C0"
android:text="#string/search"
android:layout_gravity="center"
android:iconifiedByDefault="false">
<requestFocus />
</SearchView>
</LinearLayout>
</android.support.v7.widget.Toolbar>
<View
android:id="#+id/shadow_view"
android:layout_width="match_parent"
android:layout_alignBottom="#+id/toolbar1"
android:visibility="visible"
android:layout_height="3dp"
android:background="#drawable/toolbar_shadow" />
</RelativeLayout>
<GridView
android:id="#+id/product_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:scrollbars="vertical"
android:layout_margin="15dp"
android:horizontalSpacing="10dp"
android:numColumns="2"
android:verticalSpacing="10dp">
</GridView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
To avoid the unexpected behaviour , provide the implementations of
#Override
public Object getItem(int position) {
return mProducts.get(position);
}
#Override
public long getItemId(int position) {
//return position; or better to provide some unique id
// as there is one in your code, product id
return mProducts.get(position).prod_id;
}
Note : remove notifyDataSetChanged(); in getView because it will trigger the adapter to refresh all view while they are under creating which can cause this behaviour.
Recommended Read
What is the intent of the methods getItem and getItemId in the Android class BaseAdapter?

No view found for id 0x7f0c0078 for the fragment while calling fragment from activity

In my app i have to call a fragment from activity. so that i am using Frgament mangaer. While i am running that code it throws the above exception.
this is my main activity
public class UserDashBoardActivity extends DrawerActivity {
private Context context;
private ImageButton searchBtn;
private ImageButton favBtn;
private ImageButton profileBtn;
private ImageButton reminderBtn;
private ImageButton logoutBtn;
private ImageButton notificationBtn;
private ImageView seatchIcon;
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
// slide menu items
private String[] navMenuTitles;
private TypedArray navMenuIcons;
#Override
protected void onStart() {
super.onStart();
AppActivityStatus.setActivityStarted();
AppActivityStatus.setActivityContext(context);
}
#Override
protected void onPause() {
super.onPause();
AppActivityStatus.setActivityStoped();
}
#Override
protected void onResume() {
super.onResume();
AppActivityStatus.setActivityStarted();
}
#Override
protected void onStop() {
super.onStop();
AppActivityStatus.setActivityStoped();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_user_dash_boad, menu);
return true;
}
// delete the selected event from event list added here
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_notify:
return true;
case R.id.action_favourite:
return true;
case R.id.action_navigation:
}
return super.onOptionsItemSelected(item);
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_dash_board);
context = getApplicationContext();
searchBtn = (ImageButton) findViewById(R.id.search_btn);
favBtn = (ImageButton) findViewById(R.id.fav_btn);
profileBtn = (ImageButton) findViewById(R.id.profile_btn);
reminderBtn = (ImageButton) findViewById(R.id.reminder_btn);
notificationBtn = (ImageButton) findViewById(R.id.notification_btn);
logoutBtn = (ImageButton) findViewById((R.id.logout_btn));
final EditText Search = (EditText) findViewById(R.id.emailAddress);
searchBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
Intent regAct = new Intent(getApplicationContext(), SearchActivity.class);
// Clears History of Activity
regAct.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(regAct);
}
});
favBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
//here i am calling the fragment
MyFavouritesFragment fragment = new MyFavouritesFragment();
if (fragment != null) {
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.container, fragment).commit();
}
}
});
profileBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
Intent tabAct = new Intent(getApplicationContext(), AboutCollegeFragment.class);
tabAct.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(tabAct);
}
});
}
}
this is my fragment to be called
public class MyFavouritesFragment extends Fragment {
private FavouriteDelegates favouriteDelegates = new FavouriteDelegates();
private Gson gson = new Gson();
private Context context;
private List<CollegeMO> collegeMOs = new ArrayList<>();
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final View view = inflater.inflate(R.layout.my_favourites_list_view, container, false);
return view;
}
private class FavouriteCollege extends BaseAdapter {
LayoutInflater mInflater;
TextView collegeText;
FavouriteCollege() {
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return collegeMOs.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return 0;
}
// show list values name and mobile number in contact page
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null)
convertView = mInflater.inflate(R.layout.my_favourites, null);
collegeText = (TextView) convertView.findViewById(R.id.clg_details);
collegeText.setText(collegeMOs.get(position).getCollegeName());
return convertView;
}
}
}
this is my main activity xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#color/appblue"
android:orientation="vertical">
<ImageButton
android:id="#+id/search_btn"
android:layout_width="115dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:layout_marginRight="150dp"
android:layout_marginTop="70dp"
android:background="#drawable/search_blue"
android:gravity="center" />
<TextView
android:id="#+id/searchCollege"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginRight="100dp"
android:layout_marginTop="20dp"
android:text="#string/search_college"
android:textColor="#color/green"
android:textSize="20sp" />
<ImageButton
android:id="#+id/fav_btn"
android:layout_width="115dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="50dp"
android:layout_marginLeft="150dp"
android:layout_marginRight="10dp"
android:layout_marginTop="-167dp"
android:background="#drawable/fav_blue"
android:gravity="center" />
<TextView
android:id="#+id/myFavourites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="370dp"
android:layout_marginRight="10dp"
android:layout_marginTop="-30dp"
android:text="#string/my_favourites"
android:textColor="#color/green"
android:textSize="20sp" />
<ImageButton
android:id="#+id/profile_btn"
android:layout_width="115dp"
android:layout_height="120dp"
android:layout_marginLeft="90dp"
android:layout_marginRight="150dp"
android:layout_marginTop="30dp"
android:background="#drawable/profile_blue"
android:gravity="center" />
<TextView
android:id="#+id/myProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="105dp"
android:layout_marginRight="100dp"
android:layout_marginTop="20dp"
android:text="#string/my_profile"
android:textColor="#color/green"
android:textSize="20sp" />
<ImageButton
android:id="#+id/notification_btn"
android:layout_width="115dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="150dp"
android:layout_marginRight="10dp"
android:layout_marginTop="-165dp"
android:background="#drawable/notification_blue"
android:gravity="center" />
<TextView
android:id="#+id/notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="390dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:text="#string/notification"
android:textColor="#color/green"
android:textSize="20sp" />
<ImageButton
android:id="#+id/reminder_btn"
android:layout_width="115dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="55dp"
android:layout_marginRight="200dp"
android:layout_marginTop="20dp"
android:background="#drawable/reminder_blue"
android:gravity="center" />
<TextView
android:id="#+id/reminder"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginLeft="110dp"
android:layout_marginRight="100dp"
android:layout_marginTop="20dp"
android:text="#string/reminder"
android:textColor="#color/green"
android:textSize="20sp" />
<ImageButton
android:id="#+id/logout_btn"
android:layout_width="115dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="150dp"
android:layout_marginRight="10dp"
android:layout_marginTop="-220dp"
android:background="#drawable/logout_blue"
android:gravity="center" />
<TextView
android:id="#+id/logout"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginBottom="50dp"
android:layout_marginLeft="410dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:text="#string/logout"
android:textColor="#color/green"
android:textSize="20sp" />
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="1000dp"
android:layout_height="1000dp"
android:layout_gravity="center"
>
</FrameLayout>
</LinearLayout>
this is fragment listview xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<ListView
android:id="#+id/course_detail_list_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbarStyle="outsideOverlay" />
</LinearLayout>
this is the item of myfavourite listview xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/appblue">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginBottom="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="40dp"
android:background="#color/white">
<TableRow
android:id="#+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageView
android:id="#+id/clgImage"
android:src = "#drawable/ic_launcher"
android:layout_weight="1" android:background="#color/white"
android:padding="20dip" android:gravity="center"/>
<TextView
android:id="#+id/clg_details" android:text="Row 2 column 2"
android:layout_weight="1" android:background="#color/white"
android:textColor="#000000"
android:padding="20dip" android:gravity="center"/>
<ImageView
android:id="#+id/downloadImage"
android:src = "#drawable/ic_launcher"
android:layout_weight="1" android:background="#color/white"
android:padding="20dip" android:gravity="center"/>
</TableRow>
</LinearLayout>
</LinearLayout>
you dont have container (R.id.container) in your main activity xml where you should display your fragment into.
like
<framelayout android:id="#+id/container"/> // this snippet is just for idea.

ListView Not Clickable or LongClickable

I have a custom listview but can't manage Click and LongClick on that
this is XML of ListActivity :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#id/activity_main_l2"
android:layout_marginTop="44dp"
android:layout_gravity="bottom"
android:gravity="bottom">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/main"
android:layout_gravity="center"
android:gravity="bottom"
android:visibility="visible"
android:id="#id/activity_main_search_layer">
<EditText android:id="#id/activity_main_search_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/message_field"
android:hint="#string/Search_hint"
android:textColor="#color/textFieldColor"
android:layout_gravity="center"
android:maxLines="8"
android:paddingLeft="10dp"
android:paddingTop="5dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:textSize="14dp"
android:singleLine="true"/>
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#00000000"
android:background="#ffffff"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true"
android:listSelector="#00000000"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:longClickable="true"/>
</LinearLayout>
<include layout="#layout/header1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/include"/>
<include layout="#layout/draver_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/include1"/>
</FrameLayout>
and this is XML of ListRow :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:background="#fafafa"
android:gravity="end"
android:orientation="horizontal"
android:id="#id/list_row_rl"
android:padding="5dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:descendantFocusability="blocksDescendants" >
<LinearLayout
android:orientation="vertical"
android:layout_width="70dp"
android:layout_height="fill_parent"
android:layout_weight="0"
android:focusable="false"
android:focusableInTouchMode="false">
<FrameLayout
android:layout_width="70dp"
android:layout_height="fill_parent"
android:foregroundGravity="center"
android:layout_gravity="center"
android:focusable="false"
android:focusableInTouchMode="false">
<FrameLayout
android:id="#+id/thumbnail"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:padding="3dp" android:layout_gravity="center"
android:foregroundGravity="center"
android:focusable="false"
android:focusableInTouchMode="false">
<QuickContactBadge
android:id="#+id/quickContactBadge1"
android:layout_width="52dp"
android:layout_height="52dp"
android:scaleType="fitCenter"
android:layout_gravity="center"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="52dp"
android:layout_height="52dp"
android:background="#drawable/round_frame"
android:layout_gravity="center"
android:gravity="center"
android:focusable="false"
android:focusableInTouchMode="false">
</LinearLayout>
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/rounded_counter"
android:layout_gravity="bottom|left"
android:layout_marginLeft="4dp"
android:layout_marginBottom="10dp"
android:id="#id/list_row_number_of_new_sms_layer"
android:visibility="invisible"
android:focusable="false"
android:focusableInTouchMode="false">
<TextView
android:id="#+id/Numberofsms"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="420"
android:textColor="#FFFFFF"
android:textSize="10dp"
android:textIsSelectable="false"
android:singleLine="true"
android:gravity="center"
android:layout_gravity="center"
android:textColorHighlight="#000000"
android:autoText="false"
android:layout_marginLeft="4dp"
android:layout_marginTop="3dp"
android:layout_marginRight="5dp"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#id/list_row_click_button"
android:background="#fafafa"
android:focusable="false"
android:focusableInTouchMode="false"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#id/list_row_click_layer">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="68dp"
android:id="#id/list_row_l1"
android:gravity="right|top"
android:layout_gravity="left|top"
android:focusable="false"
android:focusableInTouchMode="false">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center|left|top"
android:layout_marginRight="5dp"
android:gravity="left|top"
android:focusable="false"
android:focusableInTouchMode="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_gravity="left|top"
android:gravity="left|top"
android:focusable="false"
android:focusableInTouchMode="false">
<TextView
android:id="#+id/ContactName"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.60"
android:text="#string/ContactName"
android:textColor="#666666"
android:textSize="16dp"
android:textStyle="bold"
android:typeface="sans"
android:textAlignment="gravity"
android:layout_gravity="left|top"
android:layout_marginRight="5dp"
android:gravity="left|top"
android:phoneNumber="true"
android:layout_marginLeft="5dp"
android:maxHeight="40dp"
android:singleLine="true"
android:focusable="false"
android:focusableInTouchMode="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="#id/list_row_count"
android:singleLine="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_gravity="left|top"
android:gravity="left|top"
android:textSize="16dp"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<TextView
android:id="#+id/LastSMS"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:text="سلام امروز روز خوبی است."
android:textColor="#aeaeae"
android:textSize="12dp"
android:singleLine="true"
android:layout_marginRight="5dp"
android:phoneNumber="false"
android:layout_marginLeft="5dp"
android:layout_marginBottom="2dp"
android:linksClickable="true"
android:autoLink="web"
android:layout_gravity="center_vertical|left"
android:gravity="center|left"
android:focusable="false"
android:focusableInTouchMode="false"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#f34323"
android:focusable="false"
android:focusableInTouchMode="false">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="70dp"
android:layout_height="fill_parent"
android:layout_weight="0"
android:layout_gravity="top"
android:gravity="top"
android:focusable="false"
android:focusableInTouchMode="false">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="68dp"
android:foregroundGravity="left|top"
android:orientation="vertical"
android:layout_gravity="center|top"
android:gravity="center|top"
android:focusable="false"
android:focusableInTouchMode="false">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/list_row_draft_text"
android:id="#+id/list_row_draft_textview"
android:layout_gravity="right"
android:textSize="8dp"
android:textColor="#ff00ac"
android:visibility="invisible"
android:focusable="false"
android:focusableInTouchMode="false"/>
<TextView
android:id="#+id/Date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="5:45"
android:textColor="#aeaeae"
android:textSize="11dp"
android:gravity="center_vertical"
android:layout_gravity="right"
android:layout_marginBottom="10dp"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#f34323"
android:id="#+id/linearLayout"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
and in ListActivity :
list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
some code...
}
});
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
some code...
}
});
but non of these listener get Click or LongClick
just LongClock on one of the TextView(android:id="#+id/ContactName") work
The Adapter :
public class Adapter extends ArrayAdapter<BoxInfoObject> implements Filterable {
public Adapter(Context c, int resource, int layout, ArrayList<BoxInfoObject> d) {
super(c, resource);
this.c = c;
mOrigionalValues = new ArrayList<BoxInfoObject>(d);
mObjects = new ArrayList<BoxInfoObject>(d);
}
private static class ViewHolder {
public LinearLayout L0;
public TextView NAME, LAST, NUMBEROF, DATE, DRAFT, NUMBEROFNEW;
public QuickContactBadge Badge;
public LinearLayout L1, L2;
public int position;
public ListView list;
}
public void add(BoxInfoObject object) {
mOrigionalValues.add(object);
this.notifyDataSetChanged();
}
public Filter getFilter() {
if (mFilter == null) {
mFilter = new CustomFilter();
}
return mFilter;
}
public int getCount() {
return mObjects.size();
}
public BoxInfoObject getItem(int position) {
return mObjects.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position2, View convertView, ViewGroup parent) {
View vi = convertView;
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
vi = LayoutInflater.from(c).inflate(R.layout.list_row, null, false);
holder.L1 = (LinearLayout) vi.findViewById(R.id.list_row_l1);
holder.L0 = (LinearLayout) vi.findViewById(R.id.list_row_rl);
holder.DATE = (TextView) vi.findViewById(R.id.Date);
holder.Badge = (QuickContactBadge) vi
.findViewById(R.id.quickContactBadge1); // thumb image
holder.list = (ListView) parent.findViewById(R.id.list);
,...
vi.setTag(holder);
} else
holder = (ViewHolder) vi.getTag();
holder.position = position2;
BOX = mObjects.get(holder.position);
int APIlevel = android.os.Build.VERSION.SDK_INT;
if (APIlevel > 11)
new load(holder, position2)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
else
new load(holder, position2).execute();
return vi;
}
private class load extends AsyncTask<ViewHolder,
Void, Void> {
private final int p;
private ViewHolder h;
private String holder_NAME_string;
private int holder_l2_visible;
private String holder_NUMBEROFNew_string;
private BoxInfoObject BOX;
private QuickContactHelper QCH;
private QuickContactBadge Badge;
private String holder_Date;
private inboxQuickAction quickAction;
private String holder_text;
public load(ViewHolder holder, int p) {
this.h = holder;
this.p = p;
}
#Override
protected void onPreExecute() {
}
#Override
protected void onPostExecute(Void aVoid) {
if (h.position == p) {
h.DATE.setText(holder_Date);
if (holder_NUMBEROFNew_string != null)
if (holder_NUMBEROFNew_string.length() > 0)
h.L2.setVisibility(holder_l2_visible);
else
h.L2.setVisibility(View.GONE);
else
h.L2.setVisibility(View.GONE);
h.NUMBEROFNew.setText(holder_NUMBEROFNew_string);
notifyDataSetChanged();
}
}
#Override
protected Void doInBackground(ViewHolder... arg0) {
try {
h.DATE.setTypeface(h.font);
h.NUMBEROF.setTypeface(h.font);
h.NAME.setTypeface(h.font);
BOX = mObjects.get(p);
holder_text = BOX.getSmses().get(BOX.getSmses().size() - 1).getMessage();
holder_Date = MakeBox.StringDate(c,
BOX.get().get(BOX.get().size() - 1).getMyDate(), H);
if (BOX.getPNs().size() == 1)
QCH = new QuickContactHelper(c,
BOX.getPNs().get(0), BOX.getOPNs().get(0));
else
QCH = new QuickContactHelper(c);
try {
QCH.BadgeImage2(h.Badge, false);
Badge = QCH.getbadge();
Badge.setMode(ContactsContract.QuickContact.MODE_SMALL);
} catch (Exception e) {
}
if (BOX.getPNs().size() == 1) {
holder_NAME_string = QCH.getname();
if (holder_NAME_string == null) {
Badge.setImageResource(R.drawable.unknown);
} else {
if (QCH.holder.tId == null || QCH.holder.tId == 0)
Badge.setImageResource(R.drawable.personal);
}
} else {
Badge.setImageResource(R.drawable.multiplus);
}
int nons = BOX.getNNew();
if (nons > 0) {
holder_l2_visible = View.VISIBLE;
holder_NUMBEROFNewSMS_string = nons + "";
} else {
holder_l2_visible = View.GONE;
holder_NUMBEROFNewSMS_string = "";
}
} catch (Exception e) {
}
return null;
}
}
any suggestion ?

Spinner Visibility

I've a strange problem with my custom spinner. My implementation is to hide the spinner and only fire the choices whenever i click a button so my spinner visibility is set to INVISIBLE and only fire a list of choices and assign the selected value back to a TextView. My code works only in emulator but when i went to my actual device the list of choices is not opened and only the default value is selected back to my textview. I've tried to set spinner visibility to Visible. This time i got the choices. I remember i have another implementation with the visibility is set to INVISIBLE and it worked as desired. Any clues?
XML Layout:
<?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:background="#EEE8E0"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:weightSum="100" >
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#E69100" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="100"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#ffffff"
android:orientation="horizontal" >
<ImageView
android:id="#+id/attach4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:scaleType="fitXY"
android:src="#drawable/attach" />
<ImageView
android:id="#+id/attach3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:scaleType="fitXY"
android:src="#drawable/attach" />
<ImageView
android:id="#+id/attach2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_weight="1"
android:clickable="true"
android:scaleType="fitXY"
android:src="#drawable/attach" />
<ImageView
android:id="#+id/attach1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:scaleType="fitXY"
android:src="#drawable/attach" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true" >
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_centerInParent="true"
android:background="#222222"
android:visibility="invisible" />
<EditText
android:id="#+id/addtitle"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="#+id/selecttype"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/edittextback"
android:gravity="right|center_vertical"
android:hint="عنوان الأعلان"
android:inputType="text"
android:lines="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#444545"
android:textSize="17dp" >
</EditText>
<EditText
android:id="#+id/addbrief"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_below="#+id/addtitle"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/edittextback"
android:gravity="right|center_vertical"
android:hint="المواصفات"
android:inputType="text"
android:lines="4"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#444545"
android:textSize="17dp" />
<EditText
android:id="#+id/addprice"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/addbrief"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/edittextback"
android:gravity="right|center_vertical"
android:hint="السعر"
android:inputType="number"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#444545"
android:textSize="17dp" />
<Spinner
android:id="#+id/addmoney"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_alignLeft="#+id/addbrief"
android:layout_alignTop="#+id/addprice"
android:layout_toLeftOf="#+id/addprice"
android:background="#drawable/edittextback"
android:entries="#array/country_arrays"
android:gravity="center_horizontal|center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:prompt="#string/country_prompt"
android:textColor="#444545"
android:textSize="17dp" />
<EditText
android:id="#+id/addkilometrage"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_alignLeft="#+id/addprice"
android:layout_alignRight="#+id/addprice"
android:layout_below="#+id/addprice"
android:layout_marginTop="10dp"
android:background="#drawable/edittextback"
android:gravity="right|center_vertical"
android:hint="المسافة المقطوعة"
android:inputType="number"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#444545"
android:textSize="17dp" />
<Spinner
android:id="#+id/addkilo"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_alignLeft="#+id/addmoney"
android:layout_alignTop="#+id/addkilometrage"
android:layout_toLeftOf="#+id/addprice"
android:background="#drawable/edittextback"
android:entries="#array/kilo"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:prompt="#string/country_prompt"
android:textColor="#444545"
android:textSize="17dp" />
<Spinner
android:id="#+id/Spinner01"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_alignLeft="#+id/addkilo"
android:layout_alignRight="#+id/addkilometrage"
android:layout_below="#+id/addkilometrage"
android:layout_marginTop="10dp"
android:background="#drawable/edittextback"
android:entries="#array/year"
android:gravity="right|center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:prompt="#string/country_prompt"
android:textColor="#444545"
android:textSize="17dp" />
<EditText
android:id="#+id/EditText01"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignLeft="#+id/Spinner01"
android:layout_alignRight="#+id/Spinner01"
android:layout_below="#+id/Spinner01"
android:layout_marginTop="10dp"
android:background="#drawable/edittextback"
android:ems="10"
android:gravity="right|center_vertical"
android:hint="رقم الهاتف/الجوال"
android:inputType="number"
android:lines="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#444545"
android:textSize="17dp" />
<Button
android:id="#+id/continueregist"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignLeft="#+id/EditText01"
android:layout_alignRight="#+id/addprice"
android:layout_below="#+id/EditText01"
android:layout_marginTop="26dp"
android:background="#drawable/green_buttons"
android:text="Continue"
android:textColor="#ffffff"
android:textSize="19dp"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner_type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner_model"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:visibility="invisible" />
<ImageView
android:id="#+id/selecttype"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/addtitle"
android:layout_marginTop="20dp"
android:scaleType="fitXY"
android:src="#drawable/sell" />
<TextView
android:id="#+id/textcattype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/spinner_type"
android:layout_marginRight="21dp"
android:layout_toLeftOf="#+id/selecttype"
android:text=""
android:textSize="19dp" />
<ImageView
android:id="#+id/selectmodel"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignRight="#+id/addmoney"
android:layout_alignTop="#+id/selecttype"
android:scaleType="fitXY"
android:src="#drawable/buy" />
<TextView
android:id="#+id/textcarmodel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/selectmodel"
android:layout_toLeftOf="#+id/selectmodel"
android:text=""
android:textSize="19dp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/mainaddshekh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#222222"
android:orientation="vertical" >
</RelativeLayout>
Java Class:
public class Sell_Class extends Activity implements OnClickListener {
Spinner Type, Model;
MyAdapter adapter1;
MyAdapter2 adapter2;
EditText cartypeedit;
ImageView cartype, carmodel;
TextView cartypetext, carmodeltext;
String CarType="",CarModel;
int arr_images[] = {
R.drawable.hy,
R.drawable.hy
};
final String[] CarsType = new String[] {
"هيونداي", "هوندا",
};
final String[] Hyundai = new String[] {
"أكسنت", "أكسيل"
};
final String[] Honda = new String[] {
"أكورد", "سيفيك",
};
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mainsell);
Type = (Spinner) findViewById(R.id.spinner_type);
Model = (Spinner) findViewById(R.id.spinner_model);
cartype = (ImageView) findViewById(R.id.selecttype);
carmodel = (ImageView) findViewById(R.id.selectmodel);
cartypetext = (TextView) findViewById(R.id.textcattype);
carmodeltext = (TextView) findViewById(R.id.textcarmodel);
cartype.setOnClickListener(this);
carmodel.setOnClickListener(this);
Type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// get spinner value
cartypetext.setText(CarsType[arg2]);
CarType = CarsType[arg2];
CarModel="";
carmodeltext.setText("");
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
Model.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
if (CarType.contentEquals("هيونداي")) {
carmodeltext.setText(Hyundai[arg2]);
CarModel = Hyundai[arg2];
}
if (CarType.contentEquals("هوندا")) {
carmodeltext.setText(Honda[arg2]);
CarModel = Honda[arg2];
}
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.selecttype:
adapter1 = new MyAdapter(this, CarsType, arr_images);
Type.setAdapter(adapter1);
Type.performClick();
cartypetext.setText("");
break;
case R.id.selectmodel:
if (CarType.contentEquals("")) {
Toast.makeText(getApplicationContext(),
"Please select car first", Toast.LENGTH_LONG).show();
}
else
{
if (CarType.contentEquals("هيونداي")) {
adapter2 = new MyAdapter2(Sell_Class.this, Hyundai);
Model.setAdapter(adapter2);
Model.performClick();
carmodeltext.setText("");
}
if (CarType.contentEquals("هوندا")) {
adapter2 = new MyAdapter2(Sell_Class.this, Honda);
Model.setAdapter(adapter2);
Model.performClick();
carmodeltext.setText("");
}
}
break;
}
}
}
MyAdapter:
public class MyAdapter extends BaseAdapter {
Context c;
String[] title;
int[] pic;
LayoutInflater inflater;
Typeface font;
int arr_images[] = {
R.drawable.hy,
R.drawable.hy
};
public MyAdapter(Context context, String[] title, int[] pic) {
super();
this.c = context;
this.title = title;
this.pic = pic;
inflater = LayoutInflater.from(context);
// font = Typeface.createFromAsset(context.getAssets(),"fonts/khalaadsara.ttf");
}
#Override
public int getCount() {
return title.length;
}
public class ViewHolder {
TextView cat;
ImageView icon;
}
#Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView== null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.spinnertext, null);
holder.cat = (TextView) convertView.findViewById(R.id.titlesub);
holder.icon = (ImageView) convertView.findViewById(R.id.imageView1);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder)convertView.getTag();
}
holder.cat.setText(title[position]);
// holder.cat.setTypeface(font);
holder.icon.setImageResource(arr_images[position]);
return convertView;
}
#Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
}

ListView row containing another ListView

I am using ListView inside the row of another ListView. In wishlist.xml, I have one ListView. That items were in wishlist_items.xml, In that wishlist_items also having one more listView. that was designed in wishlist_items_advisors.xml. My problem is that send ListView is showing only one item. Can any one tell me how to fix this?
And the adapters also given below.
wishlist.xml
<LinearLayout
android:id="#+id/logo_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:contentDescription="#string/app_name" />
<LinearLayout
android:id="#+id/title_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/titleredbg"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/wishlist_title"
android:textColor="#fff"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<Button
android:id="#+id/help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:contentDescription="#string/app_name" />
<Button
android:id="#+id/add_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:contentDescription="#string/app_name"
android:padding="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="57"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="#+id/wishlist_name_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="40"
android:text="#string/wishlist_name"
android:textColor="#color/Black" />
<TextView
android:id="#+id/wishlist_email_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:text="#string/wishlist_email"
android:textColor="#color/Black" />
</LinearLayout>
<TextView
android:id="#+id/wishlist_relation_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="43"
android:text="#string/wishlist_relation"
android:textColor="#color/Black" />
</LinearLayout>
<LinearLayout
android:id="#+id/items_footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:weightSum="100" >
<ListView
android:id="#+id/listView_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#null"
android:dividerHeight="4dp"
android:visibility="visible" >
</ListView>
<LinearLayout
android:id="#+id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/no_data"
android:textColor="#000" >
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
wishlist_items.xml
<TextView
android:id="#+id/hr1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#D2D2D2" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="57"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="#+id/wishlist_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="40"
android:ellipsize="end"
android:maxLines="2"
android:text="John John John John John John"
android:textColor="#color/Black" />
<TextView
android:id="#+id/wishlist_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:ellipsize="end"
android:maxLines="2"
android:text="krishna.mondeddu#gmail.com krishna.mondeddu#gmail.com"
android:textColor="#color/Black" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="43"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="#+id/wishlist_relation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="60"
android:ellipsize="end"
android:maxLines="2"
android:text="Birthday Birthday vv Birthday Birthday"
android:textColor="#color/Black" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="40" >
<ImageButton
android:id="#+id/editButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/deleteButton"
android:background="#drawable/wishlistediticon"
android:contentDescription="#string/app_name" />
<ImageButton
android:id="#+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:contentDescription="#string/app_name" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/hr4"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#D2D2D2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<TextView
android:id="#+id/gift_advisor_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/wishlist_getadvisor"
android:textColor="#color/Black" />
</LinearLayout>
<TextView
android:id="#+id/hr1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#D2D2D2" />
<ListView android:id="#+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
></ListView>
<TextView
android:id="#+id/hr5"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#D2D2D2" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#fff"
android:paddingTop="5dp"
android:paddingBottom="5dp"
>
<ImageButton
android:id="#+id/invite_advisor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:contentDescription="#string/app_name" />
</RelativeLayout>
</LinearLayout>
wishlist_items_advisors.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="57"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="#+id/advisor_name_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="40"
android:ellipsize="end"
android:maxLines="2"
android:text="John John"
android:textColor="#color/Black" />
<TextView
android:id="#+id/advisor_email_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:ellipsize="end"
android:maxLines="2"
android:text="krishna."
android:textColor="#color/Black" />
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="43" >
<TextView
android:id="#+id/status_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/deleteButton"
android:text="Accept" />
<ImageButton
android:id="#+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:contentDescription="#string/app_name" />
</RelativeLayout>
</LinearLayout>
CustomAdapter
public class CustomAdapter extends BaseAdapter{
private String guestIds[]=null;
private String names[]=null;
private String emails[] = null;
private String relationships[] = null;
private String occasions[] = null;
DisplayImageOptions doption=null;
private ImageLoadingListener animateFirstListener =null;
private Context context=null;
public CustomAdapter(Activity activity,String[] guestId,String[] name,String[] email,String[] relationship, String[] occasion)
{
this.context=activity;
this.guestIds = guestId;
this.names =name;
this.emails = email;
this.relationships = relationship;
this.occasions = occasion;
doption=new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_empty).showImageOnFail(R.drawable.ic_error).showStubImage(R.drawable.ic_stub).cacheInMemory(true).cacheOnDisc(true).displayer(new RoundedBitmapDisplayer(5)).build();
animateFirstListener = new AnimateFirstDisplayListener();
}
#Override
public int getViewTypeCount() {
return 2;
}
#Override
public int getItemViewType(int position) {
//CustomAdapter item = (CustomAdapter) getItem(position);
if (isItemAnAd(position)) {
return 0;
} else {
return 1;
}
}
private boolean isItemAnAd(int position) {
// Place an ad at the first
return (position == 0);
}
#Override
public Object getItem(int arg0) {
return arg0;
}
#Override
public long getItemId(int arg0) {
return arg0;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
final ViewHolder holder;
if (convertView == null) {
view = ((Activity) context).getLayoutInflater().inflate(R.layout.wishlist_items, parent, false);
holder = new ViewHolder();
holder.wishlistName = (TextView) view.findViewById(R.id.wishlist_name);
holder.wishlistEmail = (TextView) view.findViewById(R.id.wishlist_email);
holder.wishlistRelation = (TextView) view.findViewById(R.id.wishlist_relation);
holder.wishGiftAdvisorText = (TextView) view.findViewById(R.id.gift_advisor_text);
holder.advisorListview = (ListView) view.findViewById(R.id.listView);
holder.inviteAdvisor = (ImageButton) view.findViewById(R.id.invite_advisor);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.wishlistName.setText(names[position]);
holder.wishlistEmail.setText(emails[position]);
holder.wishlistRelation.setText(relationships[position]);
holder.wishGiftAdvisorText.setText(getResources().getString( R.string.wishlist_getadvisor)+" "+names[position]+"'s "+getResources().getString( R.string.wishlist_title) );
GuestId = guestIds[position];
holder.wishlistName.setTypeface(tf);
holder.wishlistEmail.setTypeface(tf);
holder.wishlistRelation.setTypeface(tf);
holder.wishGiftAdvisorText.setTypeface(tf);
if(occasions[position].contains("[")) {
try {
array = new JSONArray(occasions[position]);
System.out.println(array.toString(2));
//loadOccasionData(array);
// TODO Auto-generated method stub
if(array!= null) {
advisorIds = new String[array.length()];
advisorNames = new String[array.length()];
advisorEmails = new String[array.length()];
advisorRelationships = new String[array.length()];
advisorStatuses = new String[array.length()];
for (int i = 0; i < array.length(); i++) {
JSONObject c;
try {
c = array.getJSONObject(i);
// Storing each json item in variable
advisorIds[i] = c.getString("advisor_id");
advisorNames[i] = c.getString("name");
advisorEmails[i] = c.getString("email");
advisorRelationships[i] = c.getString("relationship");
advisorStatuses[i] = c.getString("status");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
CustomAdvisorAdapter adapter = new CustomAdvisorAdapter(WishList.this,
advisorIds, advisorNames, advisorEmails, advisorRelationships , advisorStatuses);
holder.advisorListview.setAdapter(adapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
holder.advisorListview.setAdapter(null);
}
return view;
}
private class AnimateFirstDisplayListener extends SimpleImageLoadingListener {
final List<String> displayedImages = Collections.synchronizedList(new LinkedList<String>());
#Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (loadedImage != null) {
ImageView imageView = (ImageView) view;
boolean firstDisplay = !displayedImages.contains(imageUri);
if (firstDisplay) {
FadeInBitmapDisplayer.animate(imageView, 500);
displayedImages.add(imageUri);
}
}
}
}
private class ViewHolder {
public TextView wishlistName;
public TextView wishlistEmail;
public TextView wishlistRelation;
public TextView wishGiftAdvisorText;
public ListView advisorListview;
public ImageButton inviteAdvisor;
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return names.length;
}
}
CustomAdvisorAdapter
public class CustomAdvisorAdapter extends BaseAdapter{
private String advisorIds[]=null;
private String advisorNames[]=null;
private String advisorEmails[] = null;
private String advisorRelationships[] = null;
private String advisorStatuses[] = null;
DisplayImageOptions doption=null;
private ImageLoadingListener animateFirstListener =null;
private Context context=null;
public CustomAdvisorAdapter(Activity activity,String[] advisorId,String[] advisorName,String[] advisorEmail,String[] advisorRelationship, String[] advisorStatus)
{
this.context=activity;
this.advisorIds = advisorId;
this.advisorNames =advisorName;
this.advisorEmails = advisorEmail;
this.advisorRelationships = advisorRelationship;
this.advisorStatuses = advisorStatus;
doption=new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_empty).showImageOnFail(R.drawable.ic_error).showStubImage(R.drawable.ic_stub).cacheInMemory(true).cacheOnDisc(true).displayer(new RoundedBitmapDisplayer(5)).build();
animateFirstListener = new AnimateFirstDisplayListener();
}
#Override
public Object getItem(int arg0) {
return arg0;
}
#Override
public long getItemId(int arg0) {
return arg0;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent) {
View viewAdvisor = convertView;
final ViewHolder advisorHolder;
if (convertView == null) {
viewAdvisor = ((Activity) context).getLayoutInflater().inflate(R.layout.wishlist_items_advisor, parent, false);
advisorHolder = new ViewHolder();
advisorHolder.advisorNameText = (TextView) viewAdvisor.findViewById(R.id.advisor_name_text);
advisorHolder.advisorEmailText = (TextView) viewAdvisor.findViewById(R.id.advisor_email_text);
advisorHolder.statusText = (TextView) viewAdvisor.findViewById(R.id.status_text);
viewAdvisor.setTag(advisorHolder);
} else {
advisorHolder = (ViewHolder) viewAdvisor.getTag();
}
advisorHolder.advisorNameText.setText(advisorNames[position]);
advisorHolder.advisorEmailText.setText(advisorEmails[position]);
advisorHolder.statusText.setText(advisorStatuses[position]);
advisorHolder.advisorNameText.setTypeface(tf);
advisorHolder.advisorEmailText.setTypeface(tf);
advisorHolder.statusText.setTypeface(tf);
return viewAdvisor;
}
private class AnimateFirstDisplayListener extends SimpleImageLoadingListener {
final List<String> displayedImages = Collections.synchronizedList(new LinkedList<String>());
#Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (loadedImage != null) {
ImageView imageView = (ImageView) view;
boolean firstDisplay = !displayedImages.contains(imageUri);
if (firstDisplay) {
FadeInBitmapDisplayer.animate(imageView, 500);
displayedImages.add(imageUri);
}
}
}
}
private class ViewHolder {
public TextView advisorNameText;
public TextView advisorEmailText;
public TextView statusText;
}
#Override
public int getCount() {
// TODO Auto-generated method stub
return names.length;
}
}
It's not possible to make a scrollable view inside a scrollable view. But as a work around this, and only in case that this listviews doesn't take much memory if all views are loaded.
you can use this
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
public class NonScrollableListView extends ListView {
public NonScrollableListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
#Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Do not use the highest two bits of Integer.MAX_VALUE because they are
// reserved for the MeasureSpec mode
int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightSpec);
getLayoutParams().height = getMeasuredHeight();
}
}
Again, it's not good to use this workaround
you will use this non Scrollable listview in the child.xml layout by adding it as a customized UI component
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.youpackage.uiutils.NonScrollableListView
android:id="#+id/non_scrollable_listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
You can ExpandableListView in place of making custom view also for data handling you can use ExpandableListAdapter.

Categories

Resources