Trying to reorder a list. I have a layout with up arrow image on left, textview in middle and down arrow on right. XML sets images to invisible.
On list item press, I turn the arrows to visible FOR THAT ITEM. Based on up or down, I swap the list item and call myAdapter.notifyDataSetChanged() in which I set both image arrows to invisible. Works just fine, except...
The client wants the arrows to "follow" the list item till a "Done" button is pressed.
I'm having trouble wrapping my head around how I get the arrows to be visible on list item pressed +/- 1...any ideas?
Tia,
Roots
P.S. The app has a database where I store these changes vs. the volatile nature of the list views
Rootstonian said:
Trying to reorder a list. I have a layout with up arrow image on left, textview in middle and down arrow on right. XML sets images to invisible.
On list item press, I turn the arrows to visible FOR THAT ITEM. Based on up or down, I swap the list item and call myAdapter.notifyDataSetChanged() in which I set both image arrows to invisible. Works just fine, except...
The client wants the arrows to "follow" the list item till a "Done" button is pressed.
I'm having trouble wrapping my head around how I get the arrows to be visible on list item pressed +/- 1...any ideas?
Tia,
Roots
P.S. The app has a database where I store these changes vs. the volatile nature of the list views
Click to expand...
Click to collapse
Hello,
I hope I have understood your problem correctly.
Keep an int named selectedIndex. When a list item is clicked, store the index of the clicked list item in selectedIndex. Then each time the up/down arrow is pressed you should swap the list item at selectedIndex with the item at selectedIndex - 1/ selectedIndex + 1 and do selectedIndex--/selectedIndex++ depending on which arrow was pressed. Then call
myAdapter.notifyDataSetChanged().
Then finally when the "Done" button is pressed, make your arrows invisible and store the changes in the database.
Please let me know if this was helpful to you
I do that and the ITEM is swapping ok, but the arrows aren't...See if I can explain it
<upArrow> This is LiistView Row1 <downArrow>
This is ListView Row 2
If I press the downArrow, I get:
This is ListView Row 2
This is LiistView Row1
....
<upArrow> This is ListView Row 14 <downArrow>
For some reason, the arrows are at like a "random" position. I need the arrows to follow the item...like:
<upArrow> This is ListView Row 2 <downArrow>
This is LiistView Row1
Have you made a ListLayout XML that defines each row of your list to have a layout that looks something like this?
Image Text Image
You could simply make the arrow images visible for the list row which is selected and invisible for those which aren't. That way you don't have to worry about changing the positions of the images. It should work but I guess there would be a better way to do it rather than making so many ImageViews.
Can you please please post your ListLayout XML if you have already defined it? Also please explain what you do to change the position of the arrow images when they are clicked.
Custom Listview; I don't have code to "change the position", that's the TOPIC of my thread! ROFL
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:id="@+id/layout">
<ImageView android:id="@+id/up" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:src="@drawable/up"
android:gravity="left" android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
androidnClick="onClick"
android:visibility="invisible"/>
<TextView android:id="@+id/toptext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dip"
android:textStyle="bold"
android:layout_toRightOf="@+id/up" />
<TextView android:id="@+id/bottomtext" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="18dip" android:layout_below="@+id/toptext"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/up" />
<ImageView android:id="@+id/down" android:layout_width="wrap_content"
android:layout_height="30dip" android:src="@drawable/down"
android:gravity="right" android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
androidnClick="onClick"
android:visibility="invisible"/>
</RelativeLayout>
// Show arrows onClick
@Override
public void onItemClick(AdapterView<?> adapter, View v, int pos, long id) {
ImageView u = (ImageView) v.findViewById(R.id.up);
ImageView d = (ImageView) v.findViewById(R.id.down);
u.setVisibility(View.VISIBLE);
d.setVisibility(View.VISIBLE);
}
});
Click to expand...
Click to collapse
And what do you do when the arrow is clicked?
EDIT:
Can you please show the code for that too?
Not going to post actual code, but rest assured, it works. It's just a simple swap of list item, like:
// This is an "up" arrow click
temp = myList.get(pos); //where pos is row of item clicked
myList.set(pos - 1, myList.get(pos));
myList.set(pos, temp)
This works fine..tested it 100 times In my custom ArrayAdapter, if I set the up and down arrows to invisible, it works fine. Client wants the arrows to follow the item, in other words, swap the arrows too. This is the point I can't quite wrap my head around LOL
Have you tried using the ListView.getChildAt(iint) method to access the lists' rows' image views and then set them to their proper visibility in the method where you swap the items?
EDIT:
Sorry if i'm unable to help =/
Don't worry about it Like I've been saying, I just can't wrap my head around it. LOL
I'm working with setting the "tag" of each row to it's position in the list and then use "findViewWithTag", but still not having any luck.
I'm sure it's one of those "oh, duh moments" you get once you figure it out.
Thanks for trying...you did get me thinking about some new ideas and that's always a good thing!
Roots
Rootstonian said:
I do that and the ITEM is swapping ok, but the arrows aren't...See if I can explain it
<upArrow> This is LiistView Row1 <downArrow>
This is ListView Row 2
If I press the downArrow, I get:
This is ListView Row 2
This is LiistView Row1
....
<upArrow> This is ListView Row 14 <downArrow>
For some reason, the arrows are at like a "random" position. I need the arrows to follow the item...like:
<upArrow> This is ListView Row 2 <downArrow>
This is LiistView Row1
Click to expand...
Click to collapse
I assume you're using a list adapter right? Why not include the arrow status as a class member of whatever class it is that you are using as the base for the list adapter?
Yes Gene and I'm not sure what you mean. See if I can code a skeleton of what I have.
Code:
public class ReorderList extends ListActivity {
// standard on create stuff
// some code for app
// setup list adapter with my xml file
lv.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View v, int pos, long id) {
ImageView u = (ImageView) v.findViewById(R.id.up);
ImageView d = (ImageView) v.findViewById(R.id.down);
u.setVisibility(View.VISIBLE);
d.setVisibility(View.VISIBLE);
}
});
} // end ReorderList class
private class mAdapter extends ArrayAdapter<String> {
public mAdapter(Context context, int textViewResourceId,ArrayList<String>editList) {
super(context, textViewResourceId, editList);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// bunch of stuff in here, but at end, I set up and down arrows to invisible
// this works perfect, except the arrows are gone and you have to click
// on the item again to move it; client doesn't like that
// If I don't set to invisible, row 12 has the arrows
}
public void onClick(View v) {
// this just swaps items based on up or down arrow press
// works fine
}
OK, I see. You're just using "String" as the base to initialize the template. Instead, create a new class:
Code:
class MyListType{
String str;
Boolean bIsArrowEnabled;
}
Now initialize your template with MyListType:
Code:
private class mAdapter extends ArrayAdapter<MyListType> {
public mAdapter(Context context, int textViewResourceId,ArrayList<MyListType>editList) {
super(context, textViewResourceId, editList);
}
You'll have to work some other issues out using this approach, but no instead of just a string in your editList, you got a string and a boolean. The boolean is part of the class so no matter where editList ends up in the list, the boolean is part of it.
Still having problems with this. Here's a dumb question LOL...
When I hit one of my arrows, I swap the list items and call notifyDataSetChanged(), which calls the @Overrided public View getView(.....). At the end of this method, there is a return....where in the code is this "sitting" on the return? It's not back to onCreate or onResume...I toasted them and no message. But the onItemClick() listener is "active" and working in onCreate().
Gotta love Android programming
//********************** Nevemind, I got it...i think
It involved setting the tagId for each row in the list view. Based on which arrow is pressed, I set a boolean value to true. If up, set images visible to tagId - 1 or tagId + 1 for down
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A
I'm new to android development, so unsure if this is the best way to do what I want, so feel free to provide suggestions. What I want to do is simply just display some verbose text messages to the screen that will scroll and allow the user to slide up and down vertically so they can view any of the messages.
I've spent the past few days trying everything I can find on Google and I still have yet to get anything working. I have been able to successfully have the text display, append to the previous text, and scroll on its own. The common issue I have seen with my working implementations has been the ability of the user being able to scroll the vertical scroll-bars themselves. I have implemented the object properties in the xml, as well as in code, but neither have worked and I'm assuming it is just a noob mistake or some little thing i'm missing.
I have tried both a TextView as well as an EditText object. I have used them in Scrollviews, by themselves but nothing seems to work. I would prefer to use the EditText with scrollbars, but at this point I am up for anything that works. I am pasting what I have currently using the EditText. I have removed the scrollview below just to start with a simpler base.
If anyone has any ideas for what will solve my issue please let me know. I also have a device on order so I do not have the ability to try on hardware yet, so I am doing this all in the droid emulator. Unsure if that is a problem.
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="hxxp://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/path"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<org.apache.android.media.CustomVideoView
android:id="@+id/custom_videoview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3.33" />
<EditText
android:id="@+id/MessageText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine" android:layout_marginTop="100dp" android:scrollbars="vertical" android:fadeScrollbars="false" android:gravity="top" android:maxHeight="100dp" android:textSize="10sp">
<requestFocus />
</EditText>
</LinearLayout>
Hi!
I've got the following problem:
I'm on JellyBlast 3 (Gingerbread, I guess) with my Galaxy Y and I'm a little unhappy with the theme that comes with JellyBlast. I have fixed some issues but I cannot figure out how to avoid black text on dark background in Alert Dialogs. This issue makes some dialogs of the hololauncher and some other apps completely ureadable if you do not turn the screen to full brightness (what I normally don't do).
I'm not quite sure, if this is possible at all...
What I've found out so far:
In the Gingerbread source the Theme for the the Alert Dialog is hard coded:
Code:
protected AlertDialog(Context context) {
this(context, com.android.internal.R.style.Theme_Dialog_Alert);
}
I'm not yet allowed to post external links... I found the above on github in the gingerbread branch in platform_frameworks_base -> core -> java -> android -> app -> AlertDialog.java
The hololauncher uses the AlertDialog.Builder class to create the Dialogs and it uses a TextView Widget to display the text. The layout looks like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<TextView android:textAppearance="?android:textAppearanceLargeInverse" android:gravity="center_vertical" android:paddingLeft="15.0dip" android:paddingRight="15.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="?android:listPreferredItemHeight" android:drawablePadding="14.0dip" />
Here you see, that the textAppearanceLargeInverse definition of the theme is used as text color. And the theme should always be "Theme.Dialog.Alert" since this is hardcoded.
I assume that com.android.internal.R.style.Theme_Dialog_Alert refers to the Theme.Dialog.Alert styledefinition in the ROMs framework-res.apk. So I added the following line to the styles.xml in framework-res.apk -> values/styles.xml inside Theme.Dialog.Alert:
Code:
<item name="textAppearanceLargeInverse">@style/TextAppearance.Large</item>
I hoped that this would overwrite the definition of textAppearanceLargeInverse for the AlertDialog so that I will not use the inherited definition of the dark theme. The color that's referenced by @style/TextAppearance.Large is (contrary to ...Large.Inverse) is #FFFFFFFF or at least close to it.
Unfortunately this does not work and I do not understand why. I got that far to figure all this stuff out and my phone seems little impressed by my effort. It still displays dark text on dark background.
The other changes I made took effect so I do not think that I'm doing something basically wrong. Can anyone help me with that?
Kanalpiroge said:
Hi!
I
Click to expand...
Click to collapse
try this one Guide
Hi, I have a widget that I want to use as lockscreen as well ( since android 4.2+ allows it), so I need to change the layout when the widget is on the lock screen and when is on the regular screen, how can i do it? I tried to use the Intent ACTION_USER_PRESENT but my BroadcastReceiver never gets it. I have it defined in the manifest as well:
PHP:
<receiver
android:name="com.myApp.myApp.MyWidgetIntentReceiver"
android:exported="false"
android:label="widgetBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" >
</action>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/demo_widget_provider" />
</receiver>
public class MyWidgetIntentReceiver extends BroadcastReceiver{
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(Intent.ACTION_USER_PRESENT){
Log.i("TICK", intent.getAction());
}
}
}
Is there any other way that I can check when the widget is in the lock screen or not? I tried this guide as well:
http://developer.android.com/guide/topics/appwidgets/index.html#lockscreen
But how do I check that every time that I lock/unlock the screen?
Thanks!
EDIT: I ended up using Intent.ACTION_USER_PRESENT to check when the screen is unlocked, Thanks!
All of the guides/methods/apps/mods I have read are out of date and do not work on the LG G2 since updating to Lollipop. I have tried xposed framework "Remove carrier" and this does also not work for me.
I have decompiled the framework-res.apk and had a look inside for the file "res/layout/keyguard_screen_tab_unlock.xml" as per this thread but it does not exist.
I can find the following though:
In "public.xml" the following lines:
<public type="string" name="keyguard_label_text" id="0x0104039c" />
<public type="string" name="lockscreen_carrier_default" id="0x0104039e" />
In strings.xml the following line:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout androidrientation="vertical" android:background="#ff000000" androidaddingTop="20.0dip" androidaddingBottom="20.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" androidaddingStart="20.0dip" androidaddingEnd="20.0dip"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:textSize="16.0sp" android:textStyle="bold" android:textColor="#ffffffff" android:id="@id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/keyguard_label_text" />
</LinearLayout>
I wonder if I remove the 16.0sp above it will go away?
I wonder if I remove the string in quotes under the other two lines in public.xml it would go away.
Probably more to it than that.
I could not find reference to anything else anywhere that seemed like the place to affect it. It's not a big deal really. Just thought I would try to get rid of it.
just try textSize="0.0sp"
maybe in LGSystemUI?
Sorry the larger text section above was from the file named "keyguard.xml" rather than strings. Sorry, my mistake. I might try changing the "textsize=16.0sp" to "textsize=0.0sp" and see what happens.
Are you solved?
Hello, i've successfully removed the carrier and also moved the charging text right under the clock and date. You can check my thread in the themes section. I'll be releasing the version with the removed carrier and with some other nice things like unlocked weather animations, next alarm text etc in the coming day or two.
Sent from my LG-D802 using XDA Free mobile app
Is there any way to replace the text with a custom one without using xposed? And maybe in statusbar too.