ListView in a Popup with EditText Issue in Android - android

I am having an issue with scrolling of ListView in a Popup. I have an activity that has a dialog theme so that it can open up as a popup. The Popup should contain EditText at the bottom and the remaining area above it should be the ListView. When the activity is started it should start with keypad open & focus on EditText.
Issue: ListView doesn't scroll when keypad is open.
Below is my activity code:
public class CommentsActivity extends Activity{
private InputMethodManager imm;
private String commentCount;
private ShopPirateDatabase db;
private ArrayList<CommentsBean> commentsList = new ArrayList<CommentsBean>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.comments_layout);
imm = (InputMethodManager) this
.getSystemService(Context.INPUT_METHOD_SERVICE);
db=new ShopPirateDatabase(this);
if(getIntent().hasExtra("count")){
commentCount=getIntent().getExtras().getString("count");
}
ListView lvMyComments=(ListView)findViewById(R.id.lvMyComments);
lvMyComments.setVisibility(View.GONE);
final Button btnPost=(Button)findViewById(R.id.btnPost);
btnPost.setVisibility(View.GONE);
etAddComment=(EditText)findViewById(R.id.etAddComment);
RelativeLayout progressLayout=(RelativeLayout)findViewById(R.id.progressLayout);
progressLayout.setVisibility(View.VISIBLE);
TextView tvNoComments=(TextView)findViewById(R.id.tvNoComments);
tvNoComments.setVisibility(View.GONE);
imm.showSoftInput(etAddComment, InputMethodManager.SHOW_IMPLICIT);
if(Integer.parseInt(commentCount) > 0){
getCommentsFromDb();
if(commentsList!=null && commentsList.size() > 0){
progressLayout.setVisibility(View.GONE);
tvNoComments.setVisibility(View.GONE);
lvMyComments.setVisibility(View.VISIBLE);
CommentsAdapter commentsAdapter = new CommentsAdapter(
CommentsActivity.this, commentsList);
lvMyComments.setAdapter(commentsAdapter);
}
} else{
progressLayout.setVisibility(View.GONE);
tvNoComments.setVisibility(View.VISIBLE);
lvMyComments.setVisibility(View.GONE);
}
}
private void getCommentsFromDb() {
db.openDatabase();
Cursor c = db.getComments();
if (c != null) {
commentsList = null;
commentsList = new ArrayList<CommentsBean>();
if (c.moveToFirst()) {
do {
CommentsBean mBeanClass = new CommentsBean();
mBeanClass
.setCommentText(c.getString(c
.getColumnIndex(db.KEY_COMMENT_TEXT)));
mBeanClass
.setCommentedDate(c.getString(c
.getColumnIndex(db.KEY_COMMENT_DATE)));
mBeanClass
.setCommentedBy(c.getString(c
.getColumnIndex(db.KEY_COMMENT_USER)));
commentsList.add(mBeanClass);
} while (c.moveToNext());
}
}
c.close();
db.closeDatabase();
}
}
comments_layout.xml
<RelativeLayout
android:id="#+id/commentsBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="#dimen/margin_5"
android:layout_marginLeft="#dimen/margin_2"
android:layout_marginRight="#dimen/margin_5" >
<Button
android:id="#+id/btnPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="#dimen/margin_35"
android:background="#color/coupon_color"
android:paddingBottom="#dimen/margin_7"
android:paddingLeft="#dimen/margin_15"
android:paddingRight="#dimen/margin_15"
android:paddingTop="#dimen/margin_7"
android:layout_alignParentRight="true"
android:layout_marginRight="#dimen/margin_2"
android:text="Post"
android:visibility="gone"
android:textColor="#color/white"
android:textSize="#dimen/normal_textsize" />
<EditText
android:id="#+id/etAddComment"
android:layout_width="match_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="#dimen/margin_2"
android:layout_toLeftOf="#id/btnPost"
android:layout_marginRight="#dimen/margin_2"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_5"
android:hint="#string/comment_hint" />
</RelativeLayout>
<ListView
android:id="#+id/lvMyComments"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="#dimen/margin_5"
android:divider="#color/home_bg_color"
android:dividerHeight="#dimen/divider_height"
android:scrollbars="none"
android:visibility="gone" >
</ListView>
<RelativeLayout
android:id="#+id/progressLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/commentsBox"
android:layout_marginLeft="#dimen/margin_10"
android:layout_marginRight="#dimen/margin_10" >
<ProgressBar
android:id="#+id/pBarComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateDrawable="#drawable/circular_progress_bar" />
<TextView
android:id="#+id/tvWaitComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/pBarComments"
android:layout_centerHorizontal="true"
android:layout_marginLeft="#dimen/margin_5"
android:layout_marginRight="#dimen/margin_5"
android:text="Loading comments..."
android:textColor="#color/black"
android:textSize="#dimen/small_textsize" />
</RelativeLayout>
<TextView
android:id="#+id/tvNoComments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/etAddComment"
android:layout_marginLeft="#dimen/margin_15"
android:layout_marginRight="#dimen/margin_25"
android:gravity="center_vertical|center_horizontal"
android:text="No comments have been posted for this offer"
android:textColor="#color/black"
android:textSize="#dimen/normal_textsize"
android:visibility="gone" />
CommentsAdapter.java
public class CommentsAdapter extends BaseAdapter {
private Context context;
private ArrayList<CommentsBean> mArrayList = new ArrayList<CommentsBean>();
public CommentsAdapter(Context ctx, ArrayList<CommentsBean> arrayList) {
this.context = ctx;
this.mArrayList = arrayList;
}
#Override
public int getCount() {
return mArrayList.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view;
view = null;
convertView = null;
if (convertView == null) {
view = new View(context);
view = inflater.inflate(R.layout.list_comments, null);
TextView commentText = (TextView) view
.findViewById(R.id.commentText);
TextView postedDate = (TextView) view.findViewById(R.id.postedDate);
TextView userName = (TextView) view.findViewById(R.id.userName);
commentText.setText(mArrayList.get(position).getCommentText());
userName.setText(" - " + mArrayList.get(position).getCommentedBy());
String dt = mArrayList.get(position).getCommentedDate();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = null;
try {
d = sdf.parse(dt);
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy");
String convertedDate = null;
convertedDate = sdf1.format(d);
postedDate.setText(convertedDate);
}
return view;
}
}
list_comments.xml
<ImageView android:id="#+id/cmtIcon"
android:layout_width="#dimen/margin_25"
android:layout_height="#dimen/margin_25"
android:src="#drawable/comment_list_icon"
android:layout_alignParentTop="true"
android:layout_marginTop="#dimen/margin_5"
android:layout_marginLeft="#dimen/margin_5"
android:layout_alignParentLeft="true" />
<TextView
android:id="#+id/commentText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_10"
android:layout_toRightOf="#id/cmtIcon"
android:layout_alignParentTop="true"
android:layout_marginTop="#dimen/margin_5"
android:textColor="#color/black"
android:textSize="#dimen/normal_textsize" />
<TextView
android:id="#+id/postedDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/commentText"
android:layout_toRightOf="#id/cmtIcon"
android:layout_marginLeft="#dimen/margin_10"
android:layout_marginTop="#dimen/margin_5"
android:text="Posted on"
android:textColor="#color/black"
android:textSize="#dimen/small_textsize" />
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/postedDate"
android:layout_marginTop="#dimen/margin_3"
android:text="User Name"
android:layout_below="#id/commentText"
android:textColor="#color/black"
android:textSize="#dimen/normal_textsize" />

Related

BaseAdapter returns null [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 6 years ago.
I have a fragment with a foldingcell view
here is the mainfragment -
public class FriendFragmentMain extends Fragment {
private static final String TAG = FriendFragmentMain.class.getSimpleName();
private FriendsCellListAdapter friendsCellListAdapter;
private List<FriendsItem> friendsItems;
private String URL_FRIEND="http://212.224.76.127/friends/friends.json";
private FragmentActivity fragmentActivity;
private Activity mActivity;
private ListView friendsListView;
public static FriendFragmentMain newInstance(){
FriendFragmentMain friendFragmentMain = new FriendFragmentMain();
return friendFragmentMain;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.friend_fragment_main, container, false);
friendsListView = (ListView) getActivity().findViewById(R.id.friend_super_list);
friendsItems = new ArrayList<>();
friendsCellListAdapter = new FriendsCellListAdapter(mActivity, friendsItems);
friendsListView.setAdapter(friendsCellListAdapter);
friendsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
((FoldingCell) view).toggle(false);
friendsCellListAdapter.registerToggle(pos);
}
});
Cache cache = AppController.getInstance().getRequestQueue().getCache();
Cache.Entry entry = cache.get(URL_FRIEND);
if (entry != null){
try {
String data = new String(entry.data, "UTF-8");
try {
parseJsonFriend(new JSONObject(data));
} catch (JSONException e){
e.printStackTrace();
}
}catch (UnsupportedEncodingException e){
e.printStackTrace();
}
} else {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
URL_FRIEND, null, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
VolleyLog.d(TAG, "Response:" + response.toString());
if (response != null) {
parseJsonFriend(response);
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "ERROR:" + error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(jsonObjectRequest);
}
return view;
}
private void parseJsonFriend(JSONObject response){
try {
JSONArray friendArray = response.getJSONArray("friends");
for (int i =0; i < friendArray.length(); i++){
JSONObject friendObj = (JSONObject) friendArray.get(i);
FriendsItem item = new FriendsItem();
item.setId(friendObj.getInt("id"));
item.setName(friendObj.getString("name"));
item.setProfilePic(friendObj.getString("profilePic"));
item.setBackgroundImage(friendObj.getString("backgroundImage"));
item.setStatus(friendObj.getString("status"));
item.setWork(friendObj.getString("work"));
item.setLocation(friendObj.getString("location"));
String friendUrl = friendObj.isNull("website")? null : friendObj
.getString("website");
item.setWebsite(friendUrl);
friendsItems.add(item);
}
friendsCellListAdapter.notifyDataSetChanged();
} catch (JSONException e){
e.printStackTrace();
}
}
#Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mActivity = activity;
}
}
the base adapter looks like this -
public class FriendsCellListAdapter extends BaseAdapter{
private HashSet<Integer> unfoldedIndexes = new HashSet<>();
private View.OnClickListener defaultMessageButton;
private View.OnClickListener defaultViewProfileButton;
private Activity activity;
private Context context;
private LayoutInflater inflater;
private List<FriendsItem> friendsItems;
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
public FriendsCellListAdapter(Activity activity, List<FriendsItem> friendsItems){
this.activity = activity;
this.friendsItems = friendsItems;
}
#Override
public int getCount() {
return friendsItems.size();
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public Object getItem(int position) {
return friendsItems.get(position);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
if (inflater==null)
inflater = (LayoutInflater)activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FriendsItem item = friendsItems.get(position);
FoldingCell cell = (FoldingCell) convertView;
ViewHolder viewHoler;
if (cell == null){
viewHoler = new ViewHolder();
cell = (FoldingCell) inflater.inflate(R.layout.friends_cell, parent, false);
viewHoler.profilePic = (NetworkImageView) cell.findViewById(R.id.friends_profile_pic);
viewHoler.clientName = (LoginTextView) cell.findViewById(R.id.client_name);
viewHoler.friendStatus = (LoginTextView) cell.findViewById(R.id.friend_status);
viewHoler.backgroundImage = (NetworkImageView) cell.findViewById(R.id.friend_background_image);
viewHoler.friendAvatar = (NetworkImageView) cell.findViewById(R.id.friends_avatar);
viewHoler.friendName = (LoginTextView) cell.findViewById(R.id.friend_name);
viewHoler.friendLocation = (LoginTextView) cell.findViewById(R.id.friend_location);
viewHoler.friendURL = (LoginTextView) cell.findViewById(R.id.friend_url);
viewHoler.friendWork = (LoginTextView) cell.findViewById(R.id.friend_work);
cell.setTag(viewHoler);
} else {
if (unfoldedIndexes.contains(position)){
cell.unfold(true);
} else {
cell.fold(true);
}
viewHoler = (ViewHolder) cell.getTag();
}
viewHoler.clientName.setText(item.getName());
viewHoler.friendName.setText(item.getName());
//chech for empty status
if (!TextUtils.isEmpty(item.getStatus())){
viewHoler.friendStatus.setText(item.getStatus());
viewHoler.friendStatus.setVisibility(View.VISIBLE);
} else {
viewHoler.friendStatus.setVisibility(View.GONE);
}
//check for empty location
if (!TextUtils.isEmpty(item.getLocation())){
viewHoler.friendLocation.setText(item.getLocation());
viewHoler.friendLocation.setVisibility(View.VISIBLE);
} else {
viewHoler.friendLocation.setVisibility(View.GONE);
}
//check for null url
if (item.getWebsite() != null){
viewHoler.friendURL.setText(Html.fromHtml("" + item.getWebsite()+""));
viewHoler.friendURL.setMovementMethod(LinkMovementMethod.getInstance());
viewHoler.friendURL.setVisibility(View.VISIBLE);
} else {
viewHoler.friendURL.setVisibility(View.GONE);
}
//check for empty work
if (!TextUtils.isEmpty(item.getWork())){
viewHoler.friendWork.setText(item.getWork());
viewHoler.friendWork.setVisibility(View.VISIBLE);
}else {
viewHoler.friendWork.setVisibility(View.GONE);
}
//profile pic
viewHoler.profilePic.setImageUrl(item.getProfilePic(), imageLoader);
viewHoler.friendAvatar.setImageUrl(item.getProfilePic(), imageLoader);
//background image
viewHoler.backgroundImage.setImageUrl(item.getBackgroundImage(), imageLoader);
return convertView;
}
public void registerToggle(int position){
if (unfoldedIndexes.contains(position))
registerFold(position);
else
registerUnfold(position);
}
public void registerFold(int position){unfoldedIndexes.remove(position);}
public void registerUnfold(int position){
unfoldedIndexes.add(position);
}
private class ViewHolder{
NetworkImageView profilePic;
LoginTextView clientName;
LoginTextView friendStatus;
NetworkImageView backgroundImage;
NetworkImageView friendAvatar;
LoginTextView friendName;
LoginTextView friendLocation;
LoginTextView friendURL;
LoginTextView friendWork;
}
}
now when i run it it throws -
Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
at com.evolustudios.askin.askin.src.fragments.FriendFragmentMain.onCreateView(FriendFragmentMain.java:60)
this error. i am unable to find out why its throwing a null object? can anyone throw a light on why its showing null object.
the views are here- friends_cell
<com.ramotion.foldingcell.FoldingCell xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
xmlns:folding-cell="http://schemas.android.com/apk/res-auto"
folding-cell:additionalFlipsCount="2"
folding-cell:animationDuration="1300"
folding-cell:backSideColor="#color/bgBackSideColor">
<include layout="#layout/friends_content_layout"/>
<include layout="#layout/friends_cell_title_layout"/>
</com.ramotion.foldingcell.FoldingCell>
friends_cell_title_layout -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false">
<!--LEFT Part -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="155dp"
android:layout_weight="3"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="20dp"
android:background="#color/feed_item_border">
<com.android.volley.toolbox.NetworkImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/friends_profile_pic"
android:scaleType="fitCenter"/>
</RelativeLayout>
<!--RIGHT Part-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="20dp"
android:paddingEnd="20dp"
android:paddingStart="15dp"
android:paddingTop="20dp"
android:background="#color/feed_item_border">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:id="#+id/title_from_to_dots"
android:layout_marginEnd="10dp"
android:src="#drawable/from_to_purple"/>
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/client_name"
android:layout_alignTop="#+id/title_from_to_dots"
android:layout_marginTop="-5dp"
android:layout_toEndOf="#+id/title_from_to_dots"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="#android:color/holo_blue_dark"
android:textSize="16sp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="#+id/friend_profile_divider"
android:layout_below="#+id/client_name"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_toEndOf="#+id/title_from_to_dots"
android:src="#color/contentDividerLine"/>
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/friend_status"
android:layout_below="#+id/friend_profile_divider"
android:layout_toEndOf="#+id/title_from_to_dots"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="#android:color/holo_blue_dark"
android:textSize="16sp"/>
</RelativeLayout>
and friend_content_layout -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<!--Content header line-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/text_password"
android:paddingBottom="7dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="7dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:src="#drawable/menu_icon"/>
</RelativeLayout>
<!--Content header Image-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.android.volley.toolbox.NetworkImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/friend_background_image"
android:scaleType="centerCrop"/>
</RelativeLayout>
<!--Content body layout-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="6dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="9dp">
<!--avatar and name-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.android.volley.toolbox.NetworkImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/friends_avatar"
android:layout_alignParentStart="true"
android:layout_marginBottom="5dp"/>
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/friend_name"
android:layout_alignTop="#+id/friends_avatar"
android:layout_marginBottom="2dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/friends_avatar"
android:textColor="#color/mainTextColor"
android:textSize="18sp"
android:textStyle="bold"/>
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/friend_location"
android:layout_alignStart="#+id/friend_name"
android:layout_marginBottom="-2dp"
android:layout_marginStart="3dp"
android:layout_below="#+id/friend_name"
android:textColor="#a9a9a9"
android:textSize="12sp"/>
</RelativeLayout>
<!--Divider Line-->
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="9dp"
android:src="#color/contentDividerLine"/>
<!--Address Part-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/url_badge"
android:textColor="#a9a9a9"
android:layout_alignParentStart="true"
android:text="WEBSITE"/>
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/friend_url"
android:layout_alignStart="#+id/url_badge"
android:layout_below="#+id/url_badge"
android:textColor="#color/mainTextColor"
android:textSize="18sp"
android:textStyle="bold"/>
</RelativeLayout>
</LinearLayout>
<!--Divider Line-->
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="7dp"
android:src="#color/contentDividerLine"/>
<!--Work Part-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/work_badge"
android:textColor="#a9a9a9"
android:layout_alignParentStart="true"
android:text="WORK"/>
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/friend_work"
android:layout_alignStart="#+id/work_badge"
android:layout_below="#+id/work_badge"
android:textColor="#color/mainTextColor"
android:textSize="18sp"
android:textStyle="bold"/>
</RelativeLayout>
</LinearLayout>
<!--Buttons-->
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/friend_send_message"
android:layout_marginTop="16dp"
android:background="#color/btnRequest"
android:padding="10dp"
android:text="Send Message"
android:textAlignment="center"
android:textColor="#color/mainTextColor"
android:textSize="20sp"/>
<com.evolustudios.askin.askin.src.customfonts.LoginTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/friend_view_profile"
android:layout_marginTop="16dp"
android:background="#color/btnRequest"
android:padding="10dp"
android:text="View Profile"
android:textAlignment="center"
android:textColor="#color/mainTextColor"
android:textSize="20sp"/>
</LinearLayout>
</LinearLayout>
Initialize friendsItems before passing it to friendsCellListAdapter
friendsItems = new ArrayList<FriendsItem>(); // add this line
friendsCellListAdapter = new FriendsCellListAdapter(mActivity, friendsItems);
friendsListView.setAdapter(friendsCellListAdapter);

Custom adapter in fragment listview

I am trying to add a custom adapter to a listview within a fragment. It's running fine but it is not displaying anything in fragment. I've tried many methods but I am not able to get it to work. Any help would be great. Thanks in advance. Here is my code:
Fragment.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/UniFeeList"
android:layout_centerHorizontal="true"
android:clickable="true"
>
</ListView>
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_add"
android:id="#+id/addQuestion"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="10dip"
/>
</RelativeLayout>
Fragment.Java
public class UniFeedFragment extends Fragment {
ListView uniFeedListview;
FloatingActionButton askQuestion;
String stdEmail, UniEmail;
TextView tv;
Post post;
String date,time;
ListView UniFeedList;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup view = (ViewGroup) inflater.inflate(R.layout.unifeedfragment, container, false);
//Getting Time
DateFormat df = new SimpleDateFormat("HH:mm");
time = df.format(Calendar.getInstance().getTime());
//Getting Date
DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
Date today = new Date();
date = dateFormatter.format(today);
//Getting data from news feed search bar
UniFeed uniFeed = (UniFeed) getActivity();
stdEmail = uniFeed.stdEmail;
UniEmail = uniFeed.uni.getEmail();
//Setting Listview
UniFeedList = (ListView) view.findViewById(R.id.UniFeeList);
final ArrayList<Post> postArray = new ArrayList<Post>();
PostListAdapter PostList = new PostListAdapter(this.getActivity(), R.layout.activity_uni_feed ,postArray);
UniFeedList.setAdapter(PostList);
return view;
}
PostListAdapter.java
public class PostListAdapter extends BaseAdapter {
Context context = null;
ArrayList<Post> postData = new ArrayList<>();
LayoutInflater inflater;
public PostListAdapter(Context context, int activity_uni_feed, ArrayList<Post> postData){
this.context = context;
this.postData = postData;
}
#Override
public int getCount() {
return postData.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView= inflater.inflate(R.layout.unifeedpost, parent, false);
return convertView;
} }
unifeedPost.xml
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/stdProfileImage"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#mipmap/ic_launcher"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Name"
android:id="#+id/stdName"
android:layout_alignTop="#id/stdProfileImage"
android:layout_toRightOf="#+id/stdProfileImage"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Date and Time"
android:id="#+id/time"
android:layout_below="#+id/stdName"
android:layout_toRightOf="#+id/stdProfileImage"
android:layout_toEndOf="#+id/stdProfileImage" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/postContent"
android:layout_below="#id/time"
android:text="Test Post"
android:layout_marginTop="10dip"
android:layout_toRightOf="#id/stdProfileImage"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/postContent"
android:layout_toRightOf="#id/stdProfileImage"
android:layout_marginTop="10dip"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Like"
android:layout_weight="0.5"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comment"
android:layout_weight="0.5"
/>
</LinearLayout>

ViewPager Activity change content when slide

I've been looking around but I can't figure out how I can fixed this issue.
I'm using the #Dave Morrissey's Subsampling Zoom Image View, is a great library and it works perfect, but I want to do a few changes.
For each image that the user will slide I want show the specific description.
So it will be:
Pic1 |Pic2 |Pic3
DescriptionPic1 |DescriptionPic2 |DescriptionPic3
When I open it I can see the picture with below the right description but when I slide left(or right) I can see always the description of the item after.
Happens because the method getItem() get called twice to make the slider more smooth.
The problem is that I want show the right content(description) below each picture.
How can I show the content perfectly when the user slide the pics?
Any help is really appreciate.
Thanks guys
ViewPagerActivity.java
public class ViewPagerActivity extends FragmentActivity {
private ViewPager page;
private Bitmap bmImg1;
private Bitmap bmImg2;
private Bitmap bmImg3;
private String TAG;
ArrayList<Bitmap> IMAGES =new ArrayList<Bitmap>();
String[] descriptionPhoto;
int numpics=1;
private int position_pic;
private String suggested_aperture;
private String suggested_filter;
private String suggested_iso;
private String suggested_shutter;
private String suggested_shot_level;
private String suggested_lens;
private String[] shot_levelPhoto;
private String[] filterPhoto;
private String[] aperturePhoto;
private String[] shutterPhoto;
private String[] isoPhoto;
private String[] focal_lengthPhoto;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_pager);
FileInputStream fis;
FileInputStream fis2;
FileInputStream fis3;
Bundle intent=getIntent().getExtras();
descriptionPhoto = intent.getStringArray("descriptionPhoto");
numpics = (int) intent.get("numpics");
position_pic = (int) intent.get("position_pic");
suggested_aperture= intent.getString("suggested_aperture");
suggested_filter= intent.getString("suggested_filter");
suggested_iso= intent.getString("suggested_iso");
suggested_shutter= intent.getString("suggested_shutter");
suggested_shot_level= intent.getString("suggested_shot_level");
suggested_lens= intent.getString("suggested_lens");
shot_levelPhoto=intent.getStringArray("shot_levelPhoto");
filterPhoto =intent.getStringArray("filterPhoto");
aperturePhoto =intent.getStringArray("aperturePhoto");
shutterPhoto =intent.getStringArray("shutterPhoto");
isoPhoto =intent.getStringArray("isoPhoto");
focal_lengthPhoto=intent.getStringArray("focal_lengthPhoto");
TextView txtaperture_suggested = (TextView) findViewById(R.id.aperture_suggested);
TextView txtfilter_suggested = (TextView) findViewById(R.id.filter_suggested);
TextView txtiso_suggested = (TextView) findViewById(R.id.iso_suggested);
TextView txtlens_suggested = (TextView) findViewById(R.id.lens_suggested);
TextView txtshutter_suggested = (TextView) findViewById(R.id.shutter_suggested);
TextView txtshot_levelsuggested = (TextView) findViewById(R.id.shot_levelsuggested);
if (suggested_shot_level == "1") {
txtshot_levelsuggested.setText("Easy");
/*txtshot_levelPhoto2.setText("Easy");
txtshot_levelPhoto3.setText("Easy");*/
} else if (suggested_shot_level == "2") {
txtshot_levelsuggested.setText("Medium");
/* txtshot_levelPhoto2.setText("Medium");
txtshot_levelPhoto3.setText("Medium");*/
} else if (suggested_shot_level == "3") {
txtshot_levelsuggested.setText("Difficult");
/*txtshot_levelPhoto2.setText("Difficult");
txtshot_levelPhoto3.setText("Difficult");*/
} else {
txtshot_levelsuggested.setText("Pro");
/* txtshot_levelPhoto2.setText("Pro");
txtshot_levelPhoto3.setText("Pro");*/
}
txtaperture_suggested.setText(suggested_aperture);
txtfilter_suggested.setText(suggested_filter);
txtiso_suggested.setText(suggested_iso);
txtshutter_suggested.setText(suggested_shutter);
txtlens_suggested.setText(suggested_lens);
TextView txtshutterPhoto = (TextView) findViewById(R.id.shutterPhoto);
TextView txtshutterPhoto2 = (TextView) findViewById(R.id.shutterPhoto2);
TextView txtshutterPhoto3 = (TextView) findViewById(R.id.shutterPhoto3);
TextView txtshot_levelPhoto = (TextView) findViewById(R.id.shot_levelPhoto);
TextView txtshot_levelPhoto2 = (TextView) findViewById(R.id.shot_levelPhoto2);
TextView txtshot_levelPhoto3 = (TextView) findViewById(R.id.shot_levelPhoto3);
TextView txtaperturePhoto = (TextView) findViewById(R.id.aperturePhoto);
TextView txtaperturePhoto2 = (TextView) findViewById(R.id.aperturePhoto2);
TextView txtaperturePhoto3 = (TextView) findViewById(R.id.aperturePhoto3);
TextView txtfilterPhoto = (TextView) findViewById(R.id.filterPhoto);
TextView txtfilterPhoto2 = (TextView) findViewById(R.id.filterPhoto2);
TextView txtfilterPhoto3 = (TextView) findViewById(R.id.filterPhoto3);
TextView txtisoPhoto = (TextView) findViewById(R.id.isoPhoto);
TextView txtisoPhoto2 = (TextView) findViewById(R.id.isoPhoto2);
TextView txtisoPhoto3 = (TextView) findViewById(R.id.isoPhoto3);
TextView txtlensPhoto = (TextView) findViewById(R.id.lensPhoto);
TextView txtlensPhoto2 = (TextView) findViewById(R.id.lensPhoto2);
TextView txtlensPhoto3 = (TextView) findViewById(R.id.lensPhoto3);
/*txtshutterPhoto.setText(shutterPhoto[0]);
if (shutterPhoto.length > 1) {
txtshutterPhoto2.setText(shutterPhoto[1]);
if (shutterPhoto.length > 2) {
txtshutterPhoto3.setText(shutterPhoto[2]);
}
}
txtisoPhoto.setText(isoPhoto[0]);
if (isoPhoto.length > 1) {
txtisoPhoto2.setText(isoPhoto[1]);
if (isoPhoto.length > 2) {
txtisoPhoto3.setText(isoPhoto[2]);
}
}
txtfilterPhoto.setText(filterPhoto[0]);
if (filterPhoto.length > 1) {
txtfilterPhoto2.setText(filterPhoto[1]);
if ((filterPhoto.length > 2)) {
txtfilterPhoto3.setText(filterPhoto[2]);
}
}
txtaperturePhoto.setText(aperturePhoto[0]);
if (aperturePhoto.length > 1) {
txtaperturePhoto2.setText(aperturePhoto[1]);
if (aperturePhoto.length > 2) {
txtaperturePhoto3.setText(aperturePhoto[2]);
}
}*/
try {
fis = getApplicationContext().openFileInput("bmImg1");
bmImg1 = BitmapFactory.decodeStream(fis);
IMAGES.add(bmImg1);
fis.close();
/*
findViewById(R.id.note1).setVisibility(View.VISIBLE);
TextView descriptionnote = (TextView)findViewById(R.id.note1);
descriptionnote.setText(descriptionPhoto[0]);
*/
if(numpics>1){
fis2 = getApplicationContext().openFileInput("bmImg2");
bmImg2 = BitmapFactory.decodeStream(fis2);
IMAGES.add(bmImg2);
fis2.close();
/*
findViewById(R.id.note1).setVisibility(View.INVISIBLE);
findViewById(R.id.note2).setVisibility(View.VISIBLE);
TextView descriptionnote2 = (TextView)findViewById(R.id.note2);
descriptionnote2.setText(descriptionPhoto[1]);
*/
if(numpics>2){
fis3 = getApplicationContext().openFileInput("bmImg3");
bmImg3 = BitmapFactory.decodeStream(fis3);
IMAGES.add(bmImg3);
fis3.close();
/*
findViewById(R.id.note2).setVisibility(View.INVISIBLE);
findViewById(R.id.note3).setVisibility(View.VISIBLE);
TextView descriptionnote3 = (TextView)findViewById(R.id.note3);
descriptionnote3.setText(descriptionPhoto[2]);
*/
}
}
}
catch (FileNotFoundException e) {
Log.d(TAG, "file not found");
e.printStackTrace();
}
catch (IOException e) {
Log.d(TAG, "io exception");
e.printStackTrace();
}
PagerAdapter pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
page = (ViewPager)findViewById(R.id.pager);
page.setAdapter(pagerAdapter);
page.setCurrentItem(position_pic);
if(page.getCurrentItem()==0 ){
findViewById(R.id.note1).setVisibility(View.VISIBLE);
findViewById(R.id.note2).setVisibility(View.INVISIBLE);
findViewById(R.id.note3).setVisibility(View.INVISIBLE);
TextView descriptionnote = (TextView) findViewById(R.id.note1);
descriptionnote.setText(descriptionPhoto[0]);
}
if (page.getCurrentItem()==1 ) {
findViewById(R.id.note1).setVisibility(View.INVISIBLE);
findViewById(R.id.note2).setVisibility(View.VISIBLE);
findViewById(R.id.note3).setVisibility(View.INVISIBLE);
TextView descriptionnote2 = (TextView) findViewById(R.id.note2);
descriptionnote2.setText(descriptionPhoto[1]);
}
if (page.getCurrentItem()==2 ) {
findViewById(R.id.note1).setVisibility(View.INVISIBLE);
findViewById(R.id.note2).setVisibility(View.INVISIBLE);
findViewById(R.id.note3).setVisibility(View.VISIBLE);
TextView descriptionnote3 = (TextView) findViewById(R.id.note3);
descriptionnote3.setText(descriptionPhoto[2]);
}
}
#Override
public void onBackPressed() {
super.onBackPressed();
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
}
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
public int getItemPosition(Object item){
return POSITION_NONE;
}
#Override
public Fragment getItem(int position) {
ViewPagerFragment fragment = new ViewPagerFragment();
fragment.setAsset(IMAGES.get(position));
return fragment;
}
#Override
public int getCount() {
return IMAGES.size();
}
}}
This is the ViewPagerFragment
public class ViewPagerFragment extends Fragment {
private static final String BUNDLE_ASSET = "res";
private Bitmap asset;
public ViewPagerFragment() {
}
public void setAsset(Bitmap asset) {
this.asset = asset;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.view_pager_page, container, false);
/* if (savedInstanceState != null) {
if (asset == null && savedInstanceState.containsKey(BUNDLE_ASSET)) {
asset = savedInstanceState.getParcelable(BUNDLE_ASSET);
}
}*/
if (asset != null) {
SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)rootView.findViewById(R.id.imageView);
imageView.setImage(ImageSource.bitmap(asset));
}
return rootView;
}
#Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
View rootView = getView();
if (rootView != null) {
outState.putString(BUNDLE_ASSET, String.valueOf(asset));
}
}}
ViewPager.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#333">
<GridLayout
android:id="#+id/suggestedParameter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible"
android:paddingTop="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_below="#+id/textParameter"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:id="#+id/shot_levellabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/shot_levellabel"
android:layout_weight="0.10"
android:gravity="center"
android:layout_row="0"
android:layout_column="0"
android:textColor="#ffffff" />
<TextView
android:id="#+id/shot_levelsuggested"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:textColor="#90c683"
android:layout_weight="0.10"
android:layout_row="1"
android:layout_column="0"
android:textColorHint="#ffffff" />
<TextView
android:id="#+id/shot_levelPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="2"
android:layout_column="0"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<!-- <TextView
android:id="#+id/shot_levelPhoto2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="3"
android:layout_column="0" />
<TextView
android:id="#+id/shot_levelPhoto3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="4"
android:layout_column="0" />-->
<TextView
android:id="#+id/shutterPhotolabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/shutterPhotolabel"
android:layout_weight="0.10"
android:layout_row="0"
android:layout_column="1"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<TextView
android:id="#+id/shutter_suggested"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:textColor="#90c683"
android:layout_weight="0.10"
android:layout_row="1"
android:layout_column="1"
android:textColorHint="#ffffff" />
<TextView
android:id="#+id/shutterPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="2"
android:layout_column="1"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<!-- <TextView
android:id="#+id/shutterPhoto2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="3"
android:layout_column="1" />
<TextView
android:id="#+id/shutterPhoto3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="4"
android:layout_column="1" />-->
<TextView
android:id="#+id/aperturePhotolabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/aperturePhotolabel"
android:layout_weight="0.10"
android:layout_row="0"
android:layout_column="2"
android:textColor="#ffffff" />
<TextView
android:id="#+id/aperture_suggested"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:textColor="#90c683"
android:layout_weight="0.10"
android:layout_row="1"
android:layout_column="2"
android:textColorHint="#ffffff" />
<TextView
android:id="#+id/aperturePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="2"
android:layout_column="2"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<!-- <TextView
android:id="#+id/aperturePhoto2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="3"
android:layout_column="2" />
<TextView
android:id="#+id/aperturePhoto3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="4"
android:layout_column="2" />-->
<TextView
android:id="#+id/isoPhotolabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/isoPhotolabel"
android:layout_weight="0.10"
android:layout_row="0"
android:layout_column="3"
android:textColor="#ffffff" />
<TextView
android:id="#+id/iso_suggested"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:textColor="#90c683"
android:layout_weight="0.10"
android:layout_row="1"
android:layout_column="3"
android:textColorHint="#ffffff" />
<TextView
android:id="#+id/isoPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center|right"
android:layout_weight="0.10"
android:paddingRight="10dp"
android:layout_row="2"
android:layout_column="3"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<!-- <TextView
android:id="#+id/isoPhoto2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center|right"
android:layout_weight="0.10"
android:paddingRight="10dp"
android:layout_row="3"
android:layout_column="3" />
<TextView
android:id="#+id/isoPhoto3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center|right"
android:layout_weight="0.10"
android:paddingRight="10dp"
android:layout_row="4"
android:layout_column="3" />-->
<TextView
android:id="#+id/lensPhotolabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lensPhotolabel"
android:layout_weight="0.10"
android:layout_row="0"
android:layout_column="4"
android:textColor="#ffffff" />
<TextView
android:id="#+id/lens_suggested"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center|left"
android:textColor="#90c683"
android:layout_weight="0.10"
android:layout_row="1"
android:layout_column="4"
android:textColorHint="#ffffff" />
<TextView
android:id="#+id/lensPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="2"
android:layout_column="4"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<!-- <TextView
android:id="#+id/lensPhoto2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="3"
android:layout_column="4"
/>
<TextView
android:id="#+id/lensPhoto3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_weight="0.10"
android:layout_row="4"
android:layout_column="4"
/>-->
<TextView
android:id="#+id/filterPhotolabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/filterPhotolabel"
android:layout_weight="0.10"
android:layout_row="0"
android:layout_column="5"
android:textColor="#ffffff" />
<TextView
android:id="#+id/filter_suggested"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:textColor="#90c683"
android:layout_row="1"
android:layout_column="5"
android:textColorHint="#ffffff" />
<TextView
android:id="#+id/filterPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_row="2"
android:layout_column="5"
android:textColor="#ffffff"
android:textColorHint="#ffffff" />
<!-- <TextView
android:id="#+id/filterPhoto2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_row="3"
android:layout_column="5"
/>
<TextView
android:id="#+id/filterPhoto3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint=" None"
android:gravity="center"
android:layout_row="4"
android:layout_column="5"
/>-->
</GridLayout>
<!--<TextView
android:id="#+id/parameter_suggested"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="10dp"
android:textSize="14sp"
android:textColor="#FFFFFF"
android:visibility="visible"
/>
<TextView
android:id="#+id/parameter2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="10dp"
android:textSize="14sp"
android:textColor="#FFFFFF"
android:visibility="invisible"
android:text="456"
android:layout_below="#+id/parameter_suggested"
/>
<TextView
android:id="#+id/parameter3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="10dp"
android:textSize="14sp"
android:textColor="#FFFFFF"
android:visibility="visible"
android:text="789"
android:layout_below="#+id/parameter_suggested"
/>
-->
</RelativeLayout>
<RelativeLayout
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#333">
<TextView
android:id="#+id/note1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="10dp"
android:textSize="14sp"
android:textColor="#FFFFFF"
android:visibility="invisible"
/>
<TextView
android:id="#+id/note2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="10dp"
android:textSize="14sp"
android:textColor="#FFFFFF"
android:visibility="invisible"
/>
<TextView
android:id="#+id/note3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="10dp"
android:textSize="14sp"
android:textColor="#FFFFFF"
android:visibility="invisible"
/>
</RelativeLayout>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_above="#id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/text1" />
</RelativeLayout>
you should add image into Map or Array For Reloading:
#Override
public void fill(final Picture picture, int pos, Object... objects) {
image=(ImageView) view.findViewById(R.id.img_galleryadapter_image);
caption=(TextView) view.findViewById(R.id.txt_galleryadapter_caption);
if(bitmapMap.containsKey(picture.imageUrl)){
image.setImageBitmap(bitmapMap.get(picture.imageUrl));
}else {
image.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_hourglass_empty_black_48dp));
Picasso.with(context).load(picture.imageUrl).memoryPolicy(MemoryPolicy.NO_CACHE).skipMemoryCache().into(new Target() {
#Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
image.setImageBitmap(bitmap);
bitmapMap.put(picture.imageUrl, bitmap);
}
#Override
public void onBitmapFailed(Drawable drawable) {}
#Override
public void onPrepareLoad(Drawable drawable) {}
});
}
caption.setText(picture.caption);
}
add to a map:
public static Map<String,Bitmap> bitmapMap=new LinkedHashMap<>();
edit your layout in the xml file to put image then below it a textview using RelativeLayoutor once ur image and its description is aligned its upto ur java codes
After struggling and reading so many different solutions I fixed by myself the issue.
I wanted share with you my solutions maybe can help someone else.
Feel free to ask me everything about it.
This is the FragmentActivity:
public class ViewPagerActivity extends FragmentActivity {
private boolean again=false;
private ViewPager page;
private Bitmap bmImg1;
private Bitmap bmImg2;
private Bitmap bmImg3;
private String TAG;
ArrayList<Bitmap> IMAGES =new ArrayList<>();
ArrayList<String> DESCRIPTIONS =new ArrayList<>();
ArrayList<String> SHOTLEVEL=new ArrayList<>();
ArrayList<String> FILTERPHOTO=new ArrayList<>();
ArrayList<String> APERTUREPHOTO=new ArrayList<>();
ArrayList<String> SHUTTERPHOTO=new ArrayList<>();
ArrayList<String> ISOPHOTO=new ArrayList<>();
ArrayList<String> LENSPHOTO=new ArrayList<>();
String[] descriptionPhoto;
private String shot_levelPhoto;
private String shot_levelPhoto1;
private String shot_levelPhoto2;
private String filterPhoto;
private String filterPhoto1;
private String filterPhoto2;
private String aperturePhoto;
private String aperturePhoto1;
private String aperturePhoto2;
private String shutterPhoto;
private String shutterPhoto1;
private String shutterPhoto2;
private String isoPhoto;
private String isoPhoto1;
private String isoPhoto2;
private String focal_lengthPhoto;
private String focal_lengthPhoto1;
private String focal_lengthPhoto2;
private String[] shot_levelPhotoArray= new String[3];
private String[] filterPhotoArray= new String[3];
private String[] aperturePhotoArray=new String[3];
private String[] shutterPhotoArray=new String[3];
private String[] isoPhotoArray=new String[3];
private String[] focal_lengthPhotoArray=new String[3];
int numpics=1;
private int position_pic;
private String suggested_aperture;
private String suggested_filter;
private String suggested_iso;
private String suggested_shutter;
private String suggested_shot_level;
private String suggested_lens;
private LayoutInflater inflater;
private boolean firsttime;
private boolean secondtime;
private int oldposition=0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_pager);
FileInputStream fis;
FileInputStream fis2;
FileInputStream fis3;
Bundle intent=getIntent().getExtras();
descriptionPhoto = intent.getStringArray("descriptionPhoto");
numpics = (int) intent.get("numpics");
position_pic = (int) intent.get("position_pic");
suggested_aperture= intent.getString("suggested_aperture");
suggested_filter= intent.getString("suggested_filter");
suggested_iso= intent.getString("suggested_iso");
suggested_shutter= intent.getString("suggested_shutter");
suggested_shot_level= intent.getString("suggested_shot_level");
suggested_lens= intent.getString("suggested_lens");
shot_levelPhoto=intent.getString("shot_levelPhoto");
shot_levelPhoto1=intent.getString("shot_levelPhoto1");
shot_levelPhoto2=intent.getString("shot_levelPhoto2");
shot_levelPhotoArray[0] = shot_levelPhoto;
if(!shot_levelPhoto1.equals("null")){
shot_levelPhotoArray[1]=shot_levelPhoto1;
if(!shot_levelPhoto2.equals("null")){
shot_levelPhotoArray[2]=shot_levelPhoto2;
}
}
filterPhoto =intent.getString("filterPhoto");
filterPhoto1 =intent.getString("filterPhoto1");
filterPhoto2 =intent.getString("filterPhoto2");
filterPhotoArray[0]= filterPhoto;
if(!filterPhoto1.equals("null")){
filterPhotoArray[1]=filterPhoto1;
if(!filterPhoto2.equals("null")){
filterPhotoArray[2]=filterPhoto2;
}
}
aperturePhoto =intent.getString("aperturePhoto");
aperturePhoto1 =intent.getString("aperturePhoto1");
aperturePhoto2 =intent.getString("aperturePhoto2");
aperturePhotoArray[0]= aperturePhoto;
if(!aperturePhoto1.equals("null")){
aperturePhotoArray[1]=aperturePhoto1;
if(!aperturePhoto2.equals("null")){
aperturePhotoArray[2]=aperturePhoto2;
}
}
shutterPhoto =intent.getString("shutterPhoto");
shutterPhoto1 =intent.getString("shutterPhoto1");
shutterPhoto2 =intent.getString("shutterPhoto2");
shutterPhotoArray[0]= shutterPhoto;
if(!shutterPhoto1.equals("null")){
shutterPhotoArray[1]=shutterPhoto1;
if(!shutterPhoto2.equals("null")){
shutterPhotoArray[2]=shutterPhoto2;
}
}
isoPhoto =intent.getString("isoPhoto");
isoPhoto1 =intent.getString("isoPhoto1");
isoPhoto2 =intent.getString("isoPhoto2");
isoPhotoArray[0]= isoPhoto;
if(!isoPhoto1.equals("null")){
isoPhotoArray[1]=isoPhoto1;
if(!isoPhoto2.equals("null")){
isoPhotoArray[2]=isoPhoto2;
}
}
focal_lengthPhoto=intent.getString("focal_lengthPhoto");
focal_lengthPhoto1=intent.getString("focal_lengthPhoto1");
focal_lengthPhoto2=intent.getString("focal_lengthPhoto2");
focal_lengthPhotoArray[0]= focal_lengthPhoto;
if(!focal_lengthPhoto1.equals("null")){
focal_lengthPhotoArray[1]=focal_lengthPhoto1;
if(!focal_lengthPhoto2.equals("null")){
focal_lengthPhotoArray[2]=focal_lengthPhoto2;
}
}
TextView txtaperture_suggested = (TextView) findViewById(R.id.aperture_suggested);
TextView txtfilter_suggested = (TextView) findViewById(R.id.filter_suggested);
TextView txtiso_suggested = (TextView) findViewById(R.id.iso_suggested);
TextView txtlens_suggested = (TextView) findViewById(R.id.lens_suggested);
TextView txtshutter_suggested = (TextView) findViewById(R.id.shutter_suggested);
TextView txtshot_levelsuggested = (TextView) findViewById(R.id.shot_levelsuggested);
if (suggested_shot_level == "1") {
txtshot_levelsuggested.setText("Easy");
} else if (suggested_shot_level =="2") {
txtshot_levelsuggested.setText("Medium");
} else if (suggested_shot_level =="3") {
txtshot_levelsuggested.setText("Difficult");
} else if (suggested_shot_level =="4"){
txtshot_levelsuggested.setText("Pro");
}
txtaperture_suggested.setText(suggested_aperture);
txtfilter_suggested.setText(suggested_filter);
txtiso_suggested.setText(suggested_iso);
txtshutter_suggested.setText(suggested_shutter);
txtlens_suggested.setText(suggested_lens);
/* TextView txtshutterPhoto = (TextView) findViewById(R.id.shutterPhoto);
TextView txtshutterPhoto2 = (TextView) findViewById(R.id.shutterPhoto2);
TextView txtshutterPhoto3 = (TextView) findViewById(R.id.shutterPhoto3);
TextView txtshot_levelPhoto = (TextView) findViewById(R.id.shot_levelPhoto);
TextView txtshot_levelPhoto2 = (TextView) findViewById(R.id.shot_levelPhoto2);
TextView txtshot_levelPhoto3 = (TextView) findViewById(R.id.shot_levelPhoto3);
TextView txtaperturePhoto = (TextView) findViewById(R.id.aperturePhoto);
TextView txtaperturePhoto2 = (TextView) findViewById(R.id.aperturePhoto2);
TextView txtaperturePhoto3 = (TextView) findViewById(R.id.aperturePhoto3);
TextView txtfilterPhoto = (TextView) findViewById(R.id.filterPhoto);
TextView txtfilterPhoto2 = (TextView) findViewById(R.id.filterPhoto2);
TextView txtfilterPhoto3 = (TextView) findViewById(R.id.filterPhoto3);
TextView txtisoPhoto = (TextView) findViewById(R.id.isoPhoto);
TextView txtisoPhoto2 = (TextView) findViewById(R.id.isoPhoto2);
TextView txtisoPhoto3 = (TextView) findViewById(R.id.isoPhoto3);
TextView txtfocal_lengthPhoto = (TextView) findViewById(R.id.lensPhoto);
TextView txtfocal_lengthPhoto2 = (TextView) findViewById(R.id.lensPhoto2);
TextView txtfocal_lengthPhoto3 = (TextView) findViewById(R.id.lensPhoto3);*/
/* if (shot_levelPhotoArray[0] == "1") {
txtshot_levelPhoto.setText("Easy");
shot_levelPhotoArray[0] = "Easy";
*//*txtshot_levelPhoto2.setText("Easy");
txtshot_levelPhoto3.setText("Easy");*//*
} else if (shot_levelPhotoArray[0] == "2") {
txtshot_levelPhoto.setText("Medium");
shot_levelPhotoArray[0] = "Medium";
*//* txtshot_levelPhoto2.setText("Medium");
txtshot_levelPhoto3.setText("Medium");*//*
} else if (shot_levelPhotoArray[0] == "3") {
txtshot_levelPhoto.setText("Difficult");
shot_levelPhotoArray[0] = "Difficult";
*//*txtshot_levelPhoto2.setText("Difficult");
txtshot_levelPhoto3.setText("Difficult");*//*
} else {
txtshot_levelPhoto.setText("Pro");
shot_levelPhotoArray[0] = "Pro";
*//* txtshot_levelPhoto2.setText("Pro");
txtshot_levelPhoto3.setText("Pro");*//*
}
txtshutterPhoto.setText(shutterPhoto);
txtisoPhoto.setText(isoPhoto);
txtfilterPhoto.setText(filterPhoto);
txtaperturePhoto.setText(aperturePhoto);
txtfocal_lengthPhoto.setText(focal_lengthPhoto);*/
/*txtshutterPhoto.setText(shutterPhoto[0]);
if (shutterPhoto.length > 1) {
txtshutterPhoto2.setText(shutterPhoto[1]);
if (shutterPhoto.length > 2) {
txtshutterPhoto3.setText(shutterPhoto[2]);
}
}
txtisoPhoto.setText(isoPhoto[0]);
if (isoPhoto.length > 1) {
txtisoPhoto2.setText(isoPhoto[1]);
if (isoPhoto.length > 2) {
txtisoPhoto3.setText(isoPhoto[2]);
}
}
txtfilterPhoto.setText(filterPhoto[0]);
if (filterPhoto.length > 1) {
txtfilterPhoto2.setText(filterPhoto[1]);
if ((filterPhoto.length > 2)) {
txtfilterPhoto3.setText(filterPhoto[2]);
}
}
txtaperturePhoto.setText(aperturePhoto[0]);
if (aperturePhoto.length > 1) {
txtaperturePhoto2.setText(aperturePhoto[1]);
if (aperturePhoto.length > 2) {
txtaperturePhoto3.setText(aperturePhoto[2]);
}
}*/
try {
fis = getApplicationContext().openFileInput("bmImg1");
bmImg1 = BitmapFactory.decodeStream(fis);
IMAGES.add(bmImg1);
DESCRIPTIONS.add(descriptionPhoto[0]);
SHOTLEVEL.add(shot_levelPhotoArray[0]);
FILTERPHOTO.add(filterPhotoArray[0]);
APERTUREPHOTO.add(aperturePhotoArray[0]);
SHUTTERPHOTO.add(shutterPhotoArray[0]);
ISOPHOTO.add(isoPhotoArray[0]);
LENSPHOTO.add(focal_lengthPhotoArray[0]);
fis.close();
if(numpics>1){
fis2 = getApplicationContext().openFileInput("bmImg2");
bmImg2 = BitmapFactory.decodeStream(fis2);
IMAGES.add(bmImg2);
DESCRIPTIONS.add(descriptionPhoto[1]);
SHOTLEVEL.add(shot_levelPhotoArray[1]);
FILTERPHOTO.add(filterPhotoArray[1]);
APERTUREPHOTO.add(aperturePhotoArray[1]);
SHUTTERPHOTO.add(shutterPhotoArray[1]);
ISOPHOTO.add(isoPhotoArray[1]);
LENSPHOTO.add(focal_lengthPhotoArray[1]);
fis2.close();
if(numpics>2){
fis3 = getApplicationContext().openFileInput("bmImg3");
bmImg3 = BitmapFactory.decodeStream(fis3);
IMAGES.add(bmImg3);
DESCRIPTIONS.add(descriptionPhoto[2]);
SHOTLEVEL.add(shot_levelPhotoArray[2]);
FILTERPHOTO.add(filterPhotoArray[2]);
APERTUREPHOTO.add(aperturePhotoArray[2]);
SHUTTERPHOTO.add(shutterPhotoArray[2]);
ISOPHOTO.add(isoPhotoArray[2]);
LENSPHOTO.add(focal_lengthPhotoArray[2]);
fis3.close();
}
}
}
catch (FileNotFoundException e) {
Log.d(TAG, "file not found");
e.printStackTrace();
}
catch (IOException e) {
Log.d(TAG, "io exception");
e.printStackTrace();
}
PagerAdapter pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager(), descriptionPhoto[position_pic]);
page = (ViewPager)findViewById(R.id.pager);
page.setAdapter(pagerAdapter);
page.setCurrentItem(position_pic);
}
#Override
public void onBackPressed() {
super.onBackPressed();
}
public void clear() {
IMAGES.clear();
DESCRIPTIONS.clear();
SHOTLEVEL.clear();
FILTERPHOTO.clear();
APERTUREPHOTO.clear();
SHUTTERPHOTO.clear();
ISOPHOTO.clear();
LENSPHOTO.clear();
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
}
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
String description;
public ScreenSlidePagerAdapter(FragmentManager fm, String description) {
super(fm);
this.description=description;
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
super.destroyItem(container, position, object);
}
//this is called when notifyDataSetChanged() is called
#Override
public int getItemPosition(Object object) {
// refresh all fragments when data set changed
return PagerAdapter.POSITION_NONE;
}
#Override
public boolean isViewFromObject(View view, Object object) {
if(object != null){
return ((Fragment)object).getView() == view;
}else{
return false;
}
}
/*#Override
public Fragment getItem(int position) {
ViewPagerFragment fragment = new ViewPagerFragment();
fragment.setAsset(IMAGES.get(position));
return fragment;
}*/
#Override
public Fragment getItem(int index) {
ViewPagerFragment fragment = new ViewPagerFragment();
//fragment.setAsset(IMAGES.get(index));
fragment.setAsset(IMAGES.get(index), DESCRIPTIONS.get(index));
ViewPagerFragment.newInstance(index,
SHOTLEVEL.get(index),
FILTERPHOTO.get(index),
APERTUREPHOTO.get(index),
SHUTTERPHOTO.get(index),
ISOPHOTO.get(index),
LENSPHOTO.get(index)); // Pages is an array of Strings
return fragment;
}
#Override
public int getCount() {
return IMAGES.size();
}
}
}
This is the Fragment
public class ViewPagerFragment extends Fragment {
private static final String BUNDLE_ASSET = "res";
private Bitmap asset;
String descriptionPhoto;
private TextView tv;
HashMap<Bitmap, String > map;
private static Bundle bundle;
public ViewPagerFragment() {
}
/*public int setAsset(Bitmap asset) {
this.asset = asset;
return 0;
}*/
public HashMap<Bitmap, String> setAsset(Bitmap asset, String description){
map= new HashMap<>();
this.asset = asset;
this.descriptionPhoto=description;
map.put(this.asset, this.descriptionPhoto);
return map;
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.view_pager_page, container, false);
if (savedInstanceState != null) {
if (asset == null && savedInstanceState.containsKey(BUNDLE_ASSET)) {
asset = savedInstanceState.getParcelable(BUNDLE_ASSET);
}
}
if (asset != null && descriptionPhoto!=null) {
TextView descriptionnote = (TextView) rootView.findViewById(R.id.note1);
if(descriptionPhoto.equals("null")){
descriptionPhoto="No description for this picture";
}
descriptionnote.setText(descriptionPhoto);
SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)rootView.findViewById(R.id.imageView);
imageView.setImage(ImageSource.bitmap(asset));
TextView txtshot_level = (TextView) rootView.findViewById(R.id.shot_levelPhoto);
TextView txtshutterPhoto = (TextView) rootView.findViewById(R.id.shutterPhoto);
TextView txtaperturePhoto = (TextView) rootView.findViewById(R.id.aperturePhoto);
TextView txtfilterPhoto = (TextView) rootView.findViewById(R.id.filterPhoto);
TextView txtisoPhoto = (TextView) rootView.findViewById(R.id.isoPhoto);
TextView txtfocal_lengthPhoto = (TextView) rootView.findViewById(R.id.lensPhoto);
txtshot_level.setText(bundle.getString("shot_levelcontent"));
txtshutterPhoto.setText(bundle.getString("shuttercontent"));
txtisoPhoto.setText(bundle.getString("isocontent"));
txtfilterPhoto.setText(bundle.getString("filtercontent"));
txtaperturePhoto.setText(bundle.getString("aperturecontent"));
txtfocal_lengthPhoto.setText(bundle.getString("lenscontent"));
}
return rootView;
}
#Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
View rootView = getView();
if (rootView != null) {
outState.putString(BUNDLE_ASSET, String.valueOf(asset));
}
}
public static Fragment newInstance(int position,
String shot_level,
String filter,
String aperture,
String shutter,
String iso,
String lens) {
ViewPagerFragment swipeFragment = new ViewPagerFragment();
bundle = new Bundle();
if (shot_level.equals("1")) {
bundle.putString("shot_levelcontent", "Easy");
} else if (shot_level.equals("2")) {
bundle.putString("shot_levelcontent", "Medium");
} else if (shot_level.equals("3")) {
bundle.putString("shot_levelcontent", "Difficult");
} else {
bundle.putString("shot_levelcontent", "Pro");
}
bundle.putString("filtercontent", filter);
bundle.putString("aperturecontent", aperture);
bundle.putString("shuttercontent", shutter);
bundle.putString("isocontent", iso);
bundle.putString("lenscontent", lens);
swipeFragment.setArguments(bundle);
return swipeFragment;
}
}

Listview not displaying below RelativeLayout

ListView is not showing, any assistance is greatly appreciated! I am able to display products with ListView alone but I cannot figure out how to display it below my Relative Layout.
Cart.java:
public class Cart extends AppCompatActivity {
private String user;
static CartChangeListener cartChangeListener;
ProductsAdapter adaptCart;
ArrayList<Product> cartItems = new ArrayList<>();
Menu menu;
float total = (float)0.00;
float shipCost = 15;
float tax = (float)0.07;
String URI;
TextView subTotal;
TextView shipping;
TextView taxes;
TextView totals;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cart);
View header = getLayoutInflater().inflate(R.layout.activity_cart, null);
//ListView.addHeaderView(headerView);
user = MainActivity.currentAccount.getUsername();
if(user == null || user.equals("Guest")) {
shipCost = (float)0.00;
tax = (float)0.00;
}
if(user != null && !(user.equals("Guest"))) {
new getCartIcon().execute();
//View header = getLayoutInflater().inflate(R.layout.activity_cart, null);
//View footer = getLayoutInflater().inflate(R.layout.activity_search, null);
ListView listView = (ListView) findViewById(R.id.list_cart_view);
new returnCartItems().execute();
//if (!(cartItems.isEmpty())) {
adaptCart = new ProductsAdapter(Cart.this, 0, cartItems);
listView.setOnItemClickListener(new ListView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
try {
ProductsAdapter.ViewHolder holder = new ProductsAdapter.ViewHolder();
holder.product_name = (TextView) v.findViewById(R.id.product_name);
holder.product_dept = (TextView) v.findViewById(R.id.product_dept);
holder.product_desc = (TextView) v.findViewById(R.id.product_desc);
holder.product_price = (TextView) v.findViewById(R.id.product_price);
holder.product_qty = (TextView) v.findViewById(R.id.product_qty);
holder.product_img = (ImageView) findViewById(R.id.icon);
URI = "http://www.michaelscray.com/Softwear/graphics/";
String dept = "Dept: ";
String money = "$";
String qty = "Qty: ";
URI += cartItems.get(position).getProduct_img();
Uri uris = Uri.parse(URI + cartItems.get(position).getProduct_img());
URI uri = java.net.URI.create(URI);
holder.product_name.setText(cartItems.get(position).getProduct_name());
holder.product_desc.setText(cartItems.get(position).getProduct_desc());
holder.product_dept.setText(dept + cartItems.get(position).getProduct_dept());
holder.product_price.setText(money + String.valueOf(cartItems.get(position).getPrice()));
holder.product_qty.setText(qty + String.valueOf(cartItems.get(position).getProduct_qty()));
Picasso.with(getApplicationContext()).load(URI).error(R.mipmap.ic_launcher).into(holder.product_img);
} catch (Exception e) {
e.printStackTrace();
}
}
});
listView.setAdapter(adaptCart);
//}
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu_main, menu);
this.menu = menu;
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// toggle nav drawer on selecting action bar app icon/title
return true;
}
public class getCartIcon extends AsyncTask<Void, Void, Void> {
String tempUser = user;
int cartNum = 0;
float tempTotal;
#Override
protected void onPreExecute() {
subTotal = (TextView) findViewById(R.id.textView_subTotal);
shipping = (TextView) findViewById(R.id.textView_shipping);
totals = (TextView) findViewById(R.id.textView_total);
taxes = (TextView) findViewById(R.id.textView_taxes);
}
#Override
protected Void doInBackground(Void... arg0) {
if(tempUser != null) {
try {
Connection conn = ConnectDB.getConnection();
String queryString = "SELECT * FROM Orders WHERE `User_Name` = '" + tempUser + "'";
PreparedStatement st = conn.prepareStatement(queryString);
//st.setString(1, tempUser);
final ResultSet result = st.executeQuery(queryString);
while (result.next()) {
try {
tempTotal += result.getFloat("Price");
//skus.add(result.getInt("SKU"));
} catch(SQLException e) {
e.printStackTrace();
}
cartNum++;
//setTotal(result.getFloat(String.valueOf("Price")));
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
protected void onPostExecute(Void result) {
getCartItems(cartNum);
subTotal.setText(String.valueOf(tempTotal));
shipping.setText(String.valueOf(shipCost));
tax = tempTotal * tax;
taxes.setText(String.valueOf(tax));
totals.setText(String.valueOf(tempTotal + shipCost + tax));
//setTotal(tempTotal);
//super.onPostExecute(result);
}
}
public class returnCartItems extends AsyncTask<Void, Void, Void> {
String tempUser = user;
Product product = null;
List<Integer> skus = new ArrayList<>();
//String descr = "DETAILS: \n\n";
#Override
protected void onPreExecute() {
}
#Override
protected Void doInBackground(Void... arg0) {
if(tempUser != null) {
try {
Connection conn = ConnectDB.getConnection();
String queryString = "SELECT * FROM Orders WHERE `User_Name` = '" + tempUser + "'";
PreparedStatement st = conn.prepareStatement(queryString);
//st.setString(1, tempUser);
final ResultSet result = st.executeQuery(queryString);
while (result.next()) {
try {
skus.add(result.getInt("SKU"));
} catch(SQLException e) {
e.printStackTrace();
}
}
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
Connection conn = ConnectDB.getConnection();
String queryString = "SELECT * FROM Inventory";
PreparedStatement st = conn.prepareStatement(queryString);
//st.setString(1, tempUser);
final ResultSet result = st.executeQuery(queryString);
while (result.next()) {
for(int i=0; i < skus.size(); i++) {
if(skus.get(i) == result.getInt("SKU")) {
product = new Product();
product.setProduct_name(result.getString("Name"));
product.setProduct_dept(result.getString("Department"));
product.setProduct_desc(result.getString("Description"));
product.setPrice(result.getFloat("Price"));
product.setProduct_qty(result.getInt("Quantity"));
product.setProduct_img(result.getString("Image"));
cartItems.add(product);
/*
descr += "Product: " + result.getString("Name") + "\n" +
"Department: " + result.getString("Department") + "\n" +
"Price: $" + result.getFloat("Price") + "\n\n";
*/
}
}
}
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
protected void onPostExecute(Void result) {
super.onPostExecute(result);
}
}
public void setTotal(float total) {
this.total += total;
}
public float getTotal() {
return total;
}
public void getCartItems(int cart) {
MenuItem cartMenuItem = (MenuItem) menu.findItem(R.id.action_cart);
if (cart == 0) {
cartMenuItem.setIcon(R.drawable.cart0);
}
if (cart == 1) {
cartMenuItem.setIcon(R.drawable.cart1);
}
if (cart == 2) {
cartMenuItem.setIcon(R.drawable.cart2);
}
if (cart == 3) {
cartMenuItem.setIcon(R.drawable.cart3);
}
if (cart == 4) {
cartMenuItem.setIcon(R.drawable.cart4);
}
if (cart == 5) {
cartMenuItem.setIcon(R.drawable.cart5);
}
if (cart > 5) {
cartMenuItem.setIcon(R.drawable.cart5plus);
}
if (cart > 10) {
cartMenuItem.setIcon(R.drawable.cart10plus);
}
}
}
ProductsAdapter.java:
public class ProductsAdapter extends ArrayAdapter<Product> {
private Activity activity;
private ArrayList<Product> products;
private static LayoutInflater inflater = null;
String money = "$";
String dept = "Dept: ";
String qty ="Qty: ";
static String URI;
public ProductsAdapter(Activity activity, int textViewResourceId, ArrayList<Product> product) {
super(activity, textViewResourceId, product);
try {
this.activity = activity;
this.products = product;
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//imageLoader = new ImageLoader(activity.getApplicationActivity());
} catch (Exception e) {
return;
}
}
#Override
public int getCount() {
return products.size();
}
public Product getItem(Product position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
public static class ViewHolder {
public TextView product_name;
public TextView product_desc;
public TextView product_dept;
public TextView product_price;
public TextView product_qty;
public ImageView product_img;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
final ViewHolder holder;
try {
if(convertView == null) {
vi = inflater.inflate(R.layout.activity_search, parent, false);
holder = new ViewHolder();
holder.product_name = (TextView) vi.findViewById(R.id.product_name);
holder.product_dept = (TextView) vi.findViewById(R.id.product_dept);
holder.product_desc = (TextView) vi.findViewById(R.id.product_desc);
holder.product_price = (TextView) vi.findViewById(R.id.product_price);
holder.product_qty = (TextView) vi.findViewById(R.id.product_qty);
holder.product_img = (ImageView) vi.findViewById(R.id.icon);
vi.setTag(holder);
}
else {
holder = (ViewHolder) vi.getTag();
}
URI = "http://www.michaelscray.com/Softwear/graphics/";
URI += products.get(position).getProduct_img();
Uri uri = Uri.parse(URI + products.get(position).getProduct_img());
holder.product_name.setText(products.get(position).getProduct_name());
holder.product_desc.setText(products.get(position).getProduct_desc());
holder.product_dept.setText(dept + products.get(position).getProduct_dept());
holder.product_price.setText(money + String.valueOf(products.get(position).getPrice()));
holder.product_qty.setText(qty + String.valueOf(products.get(position).getProduct_qty()));
Picasso.with(getContext()).load(URI).error(R.mipmap.ic_launcher).into(holder.product_img);
}
catch(Exception e) {
}
return vi;
}
}
And, activity_cart.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/llSliderCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#5e80ab"
android:orientation="vertical" >
<TextView
android:id="#+id/summary"
android:layout_width="254dp"
android:layout_height="55dp"
android:gravity="center"
android:text="CART SUMMARY"
android:textColor="#ffffff"
android:textSize="18sp"
android:textStyle="bold"
android:layout_alignParentStart="true"
android:layout_toStartOf="#+id/checkout_btn" />
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Checkout"
android:id="#+id/checkout_btn"
android:background="#drawable/shape"
android:layout_alignParentBottom="false"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="true"
android:paddingLeft="1dp"
android:paddingTop="1dp"
android:paddingRight="1dp"
android:paddingBottom="1dp"
android:textStyle="bold"
android:textColor="#ffffff" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/cart_rows"
android:background="#ffffff"
android:orientation="horizontal" >
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingRight="20dp"
android:text="Subtotal"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/vertical_divider_welcome" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingLeft="20dp"
android:text="#string/currency"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
<TextView
android:id="#+id/textView_subTotal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingRight="20dp"
android:text="0.00"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/vertical_divider_welcome" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/cart_rows"
android:background="#ffffff"
android:orientation="horizontal" >
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingRight="20dp"
android:text="Shipping"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/vertical_divider_welcome" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingLeft="20dp"
android:text="#string/currency"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
<TextView
android:id="#+id/textView_shipping"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingRight="20dp"
android:text="0.00"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/vertical_divider_welcome" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/cart_rows"
android:background="#ffffff"
android:orientation="horizontal" >
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingRight="20dp"
android:text="Tax"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/vertical_divider_welcome" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingLeft="20dp"
android:text="#string/currency"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingRight="20dp"
android:text="0"
android:textColor="#a4a4a4"
android:textSize="#dimen/text_normal"
android:id="#+id/textView_taxes" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/vertical_divider_welcome" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/cart_rows"
android:background="#ffffff"
android:orientation="horizontal" >
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingRight="20dp"
android:text="Total"
android:textStyle="bold"
android:textColor="#color/blue"
android:textSize="#dimen/text_title" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/vertical_divider_welcome" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:paddingLeft="20dp"
android:text="#string/currency"
android:textStyle="bold"
android:textColor="#color/blue"
android:textSize="#dimen/text_title" />
<TextView
android:id="#+id/textView_total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:textStyle="bold"
android:paddingRight="20dp"
android:text="0.00"
android:textColor="#color/blue"
android:textSize="#dimen/text_title" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/vertical_divider_welcome" />
<!--
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Description"
android:id="#+id/textView" />
-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cart contents:"
android:id="#+id/contents"
android:background="#color/vertical_divider_welcome"
android:textStyle="bold|italic"
android:layout_alignParentEnd="false"
android:layout_alignParentStart="false" />
</RelativeLayout>
<ListView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:id="#+id/list_cart_view">
</ListView>
</LinearLayout>
Thanks again!
While your RelativeLayout(the one just before the ListView) have match_parent as height, it will take the remaining space of the window... so there is no place for your ListView to be shown.
Try this..
Give id to the above Relative layout and use the same below.
<ListView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_below="#id/"
android:id="#+id/list_cart_view">
</ListView>

Display Repeatation Item in ListView after three Item on Scrolling in android?

I want to fill Listview but But Repeat only imgLike,imgComments,txtLikeUnlike and txtComments from all Items. Because I using array for imgLike,imgComments,txtLikeUnlike and txtComments for get (fetch)selected Position. what is mistake in my code please guide me.
My code,
/** Adapter Class */
public class Adapter1 extends BaseAdapter {
ImageView imgImage = null,imgUnlike[] = null, imgLike[] = null,imgComments[] = null, imgShare[] = null;
TextView txtId = null,txtLikeUnlike[] = null, txtComments[] = null;
public ArrayList<HashMap<String, String>> arr = null;
Context context = null;
LayoutInflater layoutInflater = null;
HashMap<String, String> getData = new HashMap<String, String>();
public Adapter1(Context context,
ArrayList<HashMap<String, String>> arr) {
this.context = context;
this.arr = arr;
layoutInflater = LayoutInflater.from(context);
this.imgUnlike = new ImageView[arr.size()];
this.imgLike = new ImageView[arr.size()];
this.imgComments = new ImageView[arr.size()];
this.imgShare = new ImageView[arr.size()];
this.txtLikeUnlike = new TextView[arr.size()];
this.txtComments = new TextView[arr.size()];
}
#Override
public int getCount() {
return arr.size();
}
#Override
public Object getItem(int position) {
return arr.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#SuppressLint("InflateParams")
#Override
public View getView(final int position, View convertView,
ViewGroup parent) {
View row = null;
if (convertView == null) {
LayoutInflater inflater = ((Activity) context)
.getLayoutInflater();
row = inflater.inflate(R.layout.list_item, parent,
false);
} else {
row = convertView;
}
/** Initialize Widgets */
/** Imageview */
imgImage = (ImageView) row
.findViewById(R.id.imgImage);
imgUnlike[position] = (ImageView) row
.findViewById(R.id.imgUnlike);
imgLike[position] = (ImageView) row
.findViewById(R.id.imgLike);
imgComments[position] = (ImageView) row
.findViewById(R.id.imgComments);
imgShare[position] = (ImageView) row
.findViewById(R.id.imgShare);
/** TextView */
txttId = (TextView) row
.findViewById(R.id.txtId);
txtLikeUnlike[position] = (TextView) row
.findViewById(R.id.txtLikeUnlike);
txtComments[position] = (TextView) row
.findViewById(R.id.txtComments);
getData = arr.get(position);
txtId.setText(getData.get(Fragment1.TAG_ID));
imgUnlike[position]
.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
imgUnlike[position]
.setVisibility(View.INVISIBLE);
imgLike[position]
.setVisibility(View.VISIBLE);
getCurrentPosition = position;
}
});
imgLike[position].setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
imgNewsFeedLike[position].setVisibility(View.INVISIBLE);
imgNewsFeedUnlike[position].setVisibility(View.VISIBLE);
}
});
row.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(),
Detail.class);
startActivity(intent);
}
});
return row;
}
xml file is,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/masterLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/five_dp" >
<ImageView
android:id="#+id/imgImage"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_below="#+id/imgBlueStrip"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:background="#null"
android:contentDescription="#string/content_description"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imgImage"
android:background="#drawable/strip"
android:baselineAligned="false"
android:gravity="center_vertical"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="#+id/imgUnlike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:contentDescription="#string/content_description"
android:src="#drawable/unlike" />
<ImageView
android:id="#+id/imgLike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="#string/content_description"
android:src="#drawable/like"
android:visibility="invisible" />
<TextView
android:id="#+id/txtLikeUnlike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="2dp"
android:layout_toRightOf="#+id/imgUnlike"
android:background="#drawable/get_notification_bg"
android:gravity="center"
android:padding="2dp"
android:textColor="#color/white"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="#+id/imgComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:contentDescription="#string/content_description"
android:src="#drawable/comments" />
<TextView
android:id="#+id/txtComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/imgComments"
android:background="#drawable/get_"
android:gravity="center"
android:padding="2dp"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="#+id/imgShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:contentDescription="#string/content_description"
android:src="#drawable/share" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="#+id/txtId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:text="id" />
<ImageView
android:id="#+id/imgBlueStrip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtId"
android:contentDescription="#string/content_description"
android:src="#drawable/blue_strip" />
</RelativeLayout>
My Layout Display Like this,

Categories

Resources