I created a sample application from Android sample tutorial and completed all 3 exercises for Notepad. I am able to add and edit notes created. However when I try to edit the notes I am force to select the text title for editing. If I click on to the right of the text, basically any where else In the same row I am not able to edit it.
I would like to make the whole row to be select-able/editable. Please let me know how to do this. I tried to change the notes_row.xml width="fill_parent". But this did not work out. Please help me out with this. Thank you.
change your notes_row.xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="#+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView">
</TextView>
</RelativeLayout>
Related
Im pretty new to Android Development, so after like three days of trying different things with the XML Layout Design, i give up and hope for help from you guys.
What i want to achieve:
A table layout with with multiple rows, each filled with calculations im making in the background
The first three rows shall contain the input parameters, the following ~12 rows shall contain output parameters
rows 3 to 6 shall be rearrangeable, so to speak change name and shown values.
This is the concept, thats what one row should look like:
My way of trying things was:
Creating a TableRow for "Taupunkt" and "Td" and another one for three textfields and the +/- picture.
But how on earth am i supposed to insert the ">" arrows picture into the layout? Basically it should be centered between the rows.
I hope i did a clear explanation of my problem and hope that there is someone out there who can help me :)
PS.: App is going to support Android 4.0 and above
EDIT: As seen in the picture, how would i go about centering the plus/minus vertically to the textfields? Like, it should have the same space above and below it to the textfields
You can use ListView or RecyclerView as mentioned in comments.
For second question to make your view centrally aligned you can use android:gravity attribute in LinearLayout. Just made one same which is using center_vertical. Checkout -
<LinearLayout
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/standard_padding"
android:background="#drawable/rectangle_round_red"
android:gravity="center_vertical"
android:minHeight="#dimen/standard_height"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_google" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Google"
android:textColor="#android:color/white"
android:textSize="#dimen/font_18" />
</LinearLayout>
This is how it looks
Please cope with me as im new to android and i have done a lot of searching on my own, about this, and im fed up not finding a proper way.
This is my custom listview template. rowbuttonlayout.xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="19.6dp" >
</TextView>
<CheckBox
android:id="#+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="3.6dp"
android:layout_marginRight="9.6dp" >
</CheckBox>
<TextView
android:id="#+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/check"
android:layout_alignBottom="#+id/check"
android:layout_toLeftOf="#+id/check"
android:text="#string/nothing" />
</RelativeLayout>
What i want is to create something like this in this pic without the header and footer.
http://www.vogella.com/articles/AndroidListView/images/xinteractive10.png.pagespeed.ic.V0cVgp99SN.png
As on my layout ill be having another textview just before the checkbox as well. Also ill be adding a dynamic button at the footer.
Now i dont want the users to interact with my listview. Only the button should be clickable and when they click it i want to run some calculations and show them in the relevant "result" textview and to check the checkbox next to it to show that i have calculated it. Meaning i have to access each and every "result" textview and "check" checkbox in the code.
Please provide me some guidance for coding this app. Im fed up looking through very complex codes trying learn on my own. Many many thanks for your help.
Shavinka
Check out below links...
ListView + CheckBox =?
How to get checked items from android listview?
http://sunil-android.blogspot.in/2013/04/android-listview-checkbox-example.html
http://fundoocode.net/android-listview-checkbox-example-onitemclicklistener-and-onclicklistener/
http://www.mysamplecode.com/2012/07/android-listview-checkbox-example.html
I'm fairly new to Android development and planning to build a simple news reader app to further familiarize myself to the platform.
The problem is; I want each of the news-item to look like Google+'s post item below:
Well, basically a big headline picture with a title and some description underneath.
I tried to re-create it using a Button (because the whole thing needs to be clickable by the user) while setting a drawable at the top of the text. It worked quite nicely.. until I decided to add more drawables to it:
Here's my XML code (although I doubt anyone would need it):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_launcher"
android:drawablePadding="8dp"
android:drawableTop="#drawable/temp_jakarta"
android:text="Button" />
</RelativeLayout>
Can you tell me why is this happening or maybe, suggest me another way to accomplish this?
Thanks in advance!
p.s., I'm pretty sorry about the link; as a new user, SO didn't allow me to post images just yet. :(
Put everything inside a RelativeLayout and place one relative to others (event on top, this doesn't matter at all) using the layout_below/above/left_of/right_of/... etc.
See http://developer.android.com/guide/topics/ui/layout/relative.html for usage, http://developer.android.com/reference/android/widget/RelativeLayout.html for a complete reference of the RelativeLayout class and "Android Layout Tricks" series in the Developer Blog for some tips_
http://android-developers.blogspot.com.es/2009/02/android-layout-tricks-1.html
http://android-developers.blogspot.com.es/2009/02/android-layout-tricks-2-reusing-layouts.html
http://android-developers.blogspot.com.es/2009/03/android-layout-tricks-3-optimize-with.html
I'm working on an android application for my final year project. My app is about storing information and then display it out on the phone.
I figure it out by using sqlite, I'm able to store data in it, as well as retrieve it by using cursor c. But how am I able to make the retrieve data visible to the user?
example: I'm creating an app about Burger King, and I click the information about Burger King, it shows the information (when was is created etc) to the user.
This is kind of an open-ended question. If you want to present your search results to the user as a list or a grid, then use a ListView or a Gridview, and attach a CursorAdapter to your View. The CursorAdapter will read the results out of the database and provide them to the View. You'll probably want to subclass your CursorAdapter so that it generates the appropriate views for your ListView/GridView to display.
It's kind of an advanced topic, but I'm sure you can find tutorials and code samples.
If you just want to display a single data item on the screen (presumably a data item with a lot of detail), then you'll probably want to define a Dialog or Activity to present it to the user, and then read the data from the cursor and load it into the various View objects in your Dialog/Activity.
I hope this helps. It would be useful if we knew more detail about what you're trying to do.
I agree with Edward Falk on the need for more clearly defined details. In answering your question I would suggest creating some TextViews or a ListView in your xml file like so:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragmentLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<TextView
android:id="#+id/viewl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/viewvaluesLabel"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/viewvaluesLabel"
android:textAppearance="?android:attr/textAppearanceLarge" />
.
.
.
</LinearLayout>
</ScrollView>
You can then get these TextViews by their respective ids using a "R.find" statement like:
TextView view1 = (TextView)findViewById(R.id.view1);
TextView view2 = (TextView)findViewById(R.id.view2);
TextView view3 = (TextView)findViewById(R.id.view3);
and then set the data you retrieve from your database table to display in these views using code like this:
Cursor c = db.getDetails(id);
if (c.moveToFirst()) {
view1.setText(c.getString(1));
view2.setText(c.getString(2));
view3.setText(c.getString(3));
} else {
db.close();
}
Hope that helps.
Hey, I've been trying to fix this problem for a long time, The problem
is that some characters in the text are out of the screen, here is a
screenshot of what I mean:
xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#drawable/list"
android:orientation="vertical"
android:padding="15dip"
android:layout_width="fill_parent"
android:id="#+id/relativeLayout1"
android:layout_height="fill_parent">
<TextView
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:id="#+id/Munawwat_Text_TextView_text"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
Can anyone suggest a way/workaround to fix this problem?
A workaround for this is to put it into an EditText. If I put the text
into the EditText, the EditText gets horizontally scrollable
(scrollable for ~3px) which is good so you can see the characters that
are out of the screen but i dont want to let the users mess with the
text.. So:
Is it possible to not allow the users to edit in the EditText and
in the same time let the EditText get scrollable?
Is there any other view that i can put the TextView into it, so it
can get scrollable a bit so I can see the characters? (limit the
scroll of the view)
Is there a way to limit the number of characters in each line in
the TextView?
I know I asked a lot though this is one of the last problem I have so
I would really appreciate any comment/suggestion!
Thanks.
You could wrap your TextView in a ScrollView. Or make the text smaller. Or try adding padding on the left to see if it forces linebreaks.
and try to use weight :D
it limites number of caracteres in textview
android:maxLength