I installed Android SDK 21 bundle Windows x64 and get nothing but errors if I try to add any code to the initial project creation code. I tried running through the Hello World and every entry gave an error. BTW: I am a newbie with Android and Linux, but I have done a lot of Windows programming. thanks...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
EDIT: removed redundancy.
Your last Button(button_send) didn't have any parent view.
You should to put that into a view like LinearLayout or others.
Try:
1) reloading Eclipse
2) running the Project Clean.
Related
I would like to change the name of the graphics, but android studio shows an error:
"Cannot perform the refactoring. This element cannot be renamed"
On the left is a tutorial on where it works, and on the right my code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/name_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/name"
android:textAlignment="center"
style="#style/NameStyle" />
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#android:drawable/btn_star_big_on"
/>
</LinearLayout>
Refactor works only in the id window:
Why doesn't it work in XML code?
This is the first project on Kubuntu 20.04 LTS.
You are trying to rename a built in drawable of the android platform while the tutorial screenshot you posted is trying to rename the id of the view
What I mean is
The resources having the #android: as prefix are the ones that are built in the android platform and thus can't be refactored or renamed and your screenshot is trying to rename like so. You can see the dialog title Rename xyz and its occurence to which indicates what element you are trying to rename
<ImageView
android:id="#+id/imageView" // This is being changed in the screenshot
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#android:drawable/btn_star_big_on" // You are trying to change this
I am having an error that says couldn't resolve #id/search_edit_frame I don't know why,
I tried the File>Invalidate Caches> Just Restart and restart android studio also tried to change the render version all of my supported api..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
myapp="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:id="#+id/svSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="#color/textDefault"
myapp="#string/search_hint"
myapp="false" />
</LinearLayout>
I'm using Android Studio 1.2.2 and sure that it compiles android.support.v7.widget(AppCompat)
any help will be appreciated.. thanks
Use
<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/searchView"
android:iconifiedByDefault="true"
android:queryHint="Search"
android:layout_centerHorizontal="true" />
it should work
First, you can search #id/search_edit_frame in all your xml file to check where it comes from.
Second, if you are sure that there is no #id/search_edit_frame in your xml, then you can try to delete all files in your Build folder.
Try to clean your project also.
When I run my android application in Android version >=4 I got this out put(I didn't tested in android version 3):
When run the same application in android version 2.3 I got a bit different output:
You can see in second screenshot the image for about button is not visible. But when I try run the same application several times on 2.3 some times I got about image visible.Here is my code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="#layout/actionbar_with_right_button" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scrollbars="none" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/snooze_button"
android:gravity="center"
android:onClick="showRemainderSnoozeSettings"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/snooze" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/help_button"
android:gravity="center"
android:onClick="showFaq"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/help" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/about_button"
android:gravity="center"
android:onClick="showAbout"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/about" />
</LinearLayout>
</ScrollView>
I didn't understand why this is happening.
Can anyone help me to solve this issue.
Edit :
One more important thing I forgot to mention when I changed android:drawableTop="#drawable/about_button" to android:drawableTop="#drawable/help_button" of about TextView. It worked perfectly. So it can be an issue of my about_button image. So I recreated the about image again and put in all drawable folder. Even after that also I didn't get any +ve result. This issue only in 2.3 or less.
Thanks
May this help you:
Seems like this is a bug with android, where sometimes the first image in the drawable folder doesn't get displayed.....
I had a similar bug - a particular drawable was not being displayed, no matter in what ImageView. So I Added a dummy image called aaaa.png to the drawable folder and problem was solved....
I changed in eclipse background of layout and added new view (button).
I started my application but in emulator nothing changed!
What can I make? Mayby it's an Eclipse bug?
I downloaded this project from internet. Initially it had black background.
I added new View - all was OK.
But after I started changed background - and appeared this bugs
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/white"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<EditText
android:id="#+id/txtInd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</LinearLayout>
Whenever you want to test the app again, DO NOT click on your app's icon in the emulator. However, select your project, and click on
IF this doesn't work. Try cleaning your project from : Project >>> Clean
When trying to view the Graphical Layout view I am getting the following error:
The following classes could not be found - EditText (Change to
android.widget.EditText, Fix Build Path, Edit XML)
The app works fine and I can edit the XML without any problems. I just can't load the graphical layout view anymore. In the Main.java file there are no problems or errors importing the EditText widget from the Android library.
I'm using Eclipse Indigo Service Release 2. Got all the recent updates.
I'm also using the latest Android SDK Tools 20.0.1
Here is the source. I've tried the option to Source > Cleanup Document and Format just to make sure the XML was correct.
<?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" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="63dp"
android:text="#string/button1" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="" >
<requestFocus />
</EditText>
</RelativeLayout>
I managed to fix the problem.
I had to change
android:inputType=""
to
android:inputType="text"
The Graphical Layout view now works again.
this is because if you are using api 4.4W which is recently released for android wear
and Android wear doesnot support edittext
http://developer.android.com/training/building-wearables.html