Using Adapter and Item Holder, Hide views from List View - java

I want to show my text view as shown in Image Below, for which i have to
remove other Views (as I have taken a Text View, Image View and a Video View
in a single XML). I am using Item Holder to show my Text View, and
want to hide Video View and Image View together.
I m trying to code but it is not working.
itemHolder.textViewMessage = (TextView) convertView
.findViewById(R.id.messageDetail);
if (itemHolder.textViewMessage != null && messageBean.getMessage()!=null)
{
itemHolder.textViewMessage.setText(messageBean.getMessage()); // here i am showing my text messages.
itemHolder.imageview2.setVisibility(View.GONE);
itemHolder.videoView.setVisibility(View.GONE);
}
[1]: http://i.stack.imgur.com/PsKTL.png
[2]: http://i.stack.imgur.com/XYCMb.png
In images given above, I don't need extra space below text.
Here Image View and Video View are showing extra space, which
I want to get Invisible.
Here view.gone not Working

Related

How can i get Text from a view, not a Textview

i worked with AccessibilityService,everything is ok.
i want get text from screen, but it's a view, not TextView.
someone tell me how to.
it show view with Monitor, but show text too.
AccessibilityNodeInfo nodeRoot = this.getRootInActiveWindow();
List nodeInfoList = nodeRoot.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/oz");
AccessibilityNodeInfo info = nodeInfoList.get(1);
Log.d(TAG, info.getText());
example
you how set text for this View?
when settext for view: You can set a tag for this view and save this tag and its value in hashmap(key is tag) and retrieve it when needed by tag.

Android: Can we add recyclerview dynamically in layout

Like any other dynamic view we can add that view dynamically into layout, is it possible with recyclerview that we can add/create dynamically and attach into a viewgroup?
Thanks
RecyclerView.LayoutParams lparams = new RecyclerView.LayoutParams(
RecyclerView.LayoutParams.WRAP_CONTENT, RecyclerView.LayoutParams.WRAP_CONTENT);
RecyclerView recyclerView = new RecyclerView(this);
recyclerView.setLayoutParams(lparams);
rootview.addView(recyclerView);
Here rootview is linear layout or any other view group of your layout XML file after that you can add Adapter to this recycle view as usual. Here you can add any number of recycle view using rootview.addView(recyclerView);

How to remove or change Recyclerview footer?

I am using this EndlessRecyclerView.java class to add footer or load more view to the RecyclerView. I have set a footer using the setProgressView() of the EndlessRecyclerView.java i.e.
mRecyclerView.setProgressView(R.layout.recyclerview_footer_layout);
Now after a specific situation, say after a network timeout, I want to change the TextView value in footer. But I am unable to do so using the follwing code:
View progressView = inflater.inflate(R.layout.recyclerview_footer_layout, null);
progressViewText = (TextView) progressView.findViewById(R.id.loadMoreText);
What is wrong here?

GridView not fitting to the screen

I am trying to learn android development from Udacity.
I am trying to use picaso to populate a grid view and try to find the images fit the screen.
Desired output should be some thing like this.
output required
The output which I am getting.
output I am getting
My xml file
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="2"
android:gravity="center"
android:stretchMode="columnWidth"
/>
My getView method from adapter class which extends BaseAdapter.
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView iImageView;
if(convertView == null){
iImageView = new ImageView(mContext);
}else {
iImageView = (ImageView) convertView;
}
Picasso.with(mContext)
.load(imageResource[0])
.into(iImageView);
iImageView.setLayoutParams(new GridView
.LayoutParams(GridView.LayoutParams.WRAP_CONTENT
, GridView.LayoutParams.WRAP_CONTENT));
Log.v("data", "Height:" + Integer.toString(iImageView.getHeight()));
Log.v("data", "Width:" + Integer.toString(iImageView.getWidth()));
return iImageView;
}
Issue that I am facing is that there is a white space between each column and between the borders of the screen. I don't want that. I want it to be like me desired output.
Please help. Thanks.
Instead of using new ImageView to create an ImageView with no properties set, try inflating a layout that contains the ImageView along with the properties for that ImageView that makes sense. For example, you'll probably want to set android:scaleType to "centerCrop". Currently it looks like the images are being scaled down to fit the space given by GridView, because it's not a perfect fit.
You could also call methods on your ImageView to set various properties, but I think for you it might be better to express it in an XML layout.
Try use custom layout with simple Linear or Relative. Set background color for this layout end set math parent for width. Somethime color for background help so much

How to know the status of the pages in a ViewPager

I'm implementing a image gallery with a ViewPager.
Each page load a image from Internet and put it in a ImageView.
The gallery also have a share button (external to the ViewPager).
I want to disable the button when the image is loading and re-enable it when the image is visible.
How can I know the status of the current page (if the image is beeing displayed or not) from the Activity containing the ViewPager?
Thanks
You can override setPrimaryItem function
public void setPrimaryItem(android.view.ViewGroup container,
int position, Object object) {
super.setPrimaryItem(container, position, object);
//check if image is loaded here
};

Categories

Resources