Tag: android-layout

How to get selected text from edittext in android?

I have a edittext in which some text are selected . I want to get only selected text from edittext on click of button . Please suggest me usable link or sample code.

RelativeLayout weight

I do have 3 RelativeLayout which is inside the main_RelativeLayout. The view will be vertically. So, I have 3 RelativeLayout which setted next to each other, and I want them to fill the whole screen, doesnt matter what will be the screen size. My, layout view: <RelativeLayout 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:background=”@drawable/backg” > <ImageView android:id=”@+id/imageView1″ […]

Hide keyboard after user searches?

Ok so I have an activity where there is an EditText and on enter key search results are shown, so what I simply want to do is to close the keyboard when search results are about to show to prevent the user from having to do it. However if the user wants to refine his […]

Getting the width/height of a layout in Android

I’m wondering how to measure the dimensions of a view. In my case it is aan Absolute Layout. I’ve read the answers concerning those questions but I still don’t get it. I’m fairly new to programming so maybe it’s just me. 😉 This is my code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AbsoluteLayout layoutbase […]

Custom View calling startActivityForResult

I created custom compound view where I incorporate functionality to take pictures. I’m calling it like this (from view): Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); ((Activity)mContext).startActivityForResult(intent, index); This part works good. What I don’t know how to do is how do I implement onActivityResult inside my custom view? Or should I catch this inside Activity and […]

Kotlin Android extensions and retained fragment

I am using Kotlin Android extensions in my project and I came across some behavior that I am unable to understand. I use this code to retain my fragment in the activity: val fragment = fragmentManager.findFragmentByTag(“hello”) ?: HelloFragment() fragmentManager.beginTransaction() .replace(R.id.fragment_container, fragment, “hello”) .commit() This is the retained Fragment: import kotlinx.android.synthetic.hello.* public class HelloFragment : Fragment() […]

Programatically change the layout color of layout

I am trying to programatically change the layout color but of a relative layout (tried Linear layout but didn’t change), but cannot change it. Also trying to debug the app doesn’t help, there was not message related to my TAG. the application stood still after layout was colored initially. package com.test.intentdemo; import android.app.Activity; import android.graphics.Color; […]

what is the use of the layoutinflator?

I’m a new Android developer. I have tried to understand the use of Layout inflator from the documentation but have not been able to understand. what is the use of layout inflator in android? What are the situations when one would have to use it?

This RelativeLayout layout or its LinearLayout parent is useless

I’m developing an Android 3.1. and above application. On one activity I generate its layout dynamically. I’m using formdetail.xml as contentview: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.formdetail); Bundle extras = getIntent().getExtras(); if (extras != null) { currentFormId = extras.getString(“FormId”); } } formdetail.xml : <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/detailLayout” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > […]

Capture RatingBar Click

I seem to have a problem with catching my ratingbar click. The ratings bar is showing up just fine and has the default value. The only problem is that I cannot change any values or it isn’t enabled. I have tried numerous different things (e.g. enabling in the layout, building it entirely in java). None […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.