android-xml

Connection between View in the xml file and extened View class

瘦欲@ 提交于 2019-12-04 16:45:47
Is there a way to link inherit class to xml file. I am trying to connect extended class to widget in the xml file. Is it possible ? Thanks in advance. You must have noticed that all the nodes that we specify in the layout XMLs are actually either View classes(for e.g: TextView, EditView) or view containers/layout managers(e.g: LinearLayout, RelativeLayout etc.). Android allows you to create custom views and containers by extending the View class and one of the layout managers, respectively. You can then choose to inflate such views directly from code or specify them as nodes in your layout

Using ImageView as background for an Android Layout

拟墨画扇 提交于 2019-12-04 11:41:31
问题 I want to take advantage of the scaleType property, which I cannot use if I set my image using the background property on the LinearLayout . I've tried using a LinearLayout with 2 children: the first is an ImageView (for the background image) and the second child is another LinearLayout containing TextViews , Buttons, etc. But the result is just the image followed by the other views. Is it possible to float the nested LinearLayout over the ImageView somehow? I know that there's lots of

Can't remove overlay view

。_饼干妹妹 提交于 2019-12-04 11:27:01
Update I was able to fix this, The problem was dialogs and related could be initiated from broadcast receiver but not recommended, as the activity running ends before the view. Trying to implement overlay like fb messenger, truecaller etc. public class IncomingCall extends BroadcastReceiver { private Context pcontext; private static final String TAG = "CustomBroadcastReceiver"; TelephonyManager telephony; CustomPhoneStateListener customPhoneListener ; @Override public void onReceive(Context context, Intent intent) { pcontext = context; Bundle extras = intent.getExtras(); if (extras != null) {

Reference attribute enum value

不羁的心 提交于 2019-12-04 10:29:10
Is it possible to reference an enum value when supplying style parameters? For example, we can do: <!-- layouts.xml --> <TextView android:text="@string/str" /> <!-- values.xml --> <item type="string" name="str">hi</item> This works fine with strings, integers, dimensions and so on but I need to reference an enum value - for example the visibility attribute. I'm looking for something like: <!-- layouts.xml --> <TextView android:visibility="@????/viz" /> <!-- values.xml --> <item type="?????" name="viz">gone</item> visibility is only an example - it could be any other enum based attribute. The

selectableItemBackground as item in layer-list

不打扰是莪最后的温柔 提交于 2019-12-04 09:57:02
问题 I've copied a file from the Google IO Schedule app source (https://github.com/google/iosched) namely selected_navdrawer_item_background.xml <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/backgroundColor"> <shape> <solid android:color="#12000000" /> </shape> </item> <item android:drawable="?android:selectableItemBackground"/> </layer-list> I want to use this to highlight the currently selected item in a NavigationDrawer. My problem is, when I

How to retrieve 2D array from xml string resource for Android?

蹲街弑〆低调 提交于 2019-12-04 09:00:23
问题 Suppose I have stored a 2 dimensional array in android resource as shown below. How can I get them in a java collection like Arraylist? <resources> <string-array name="countries_array"> <item> <name>Bahrain</name> <code>12345</code> </item> <item> <name>Bangladesh</name> <code>54545</code> </item> <item> <name>India</name> <code>54455</code> </item> </string-array> </resources> For example in case of 1 dimensional array we can do it using getResources().getStringArray(R.array.countries_array)

Android Dim Background of Custom Dialog

青春壹個敷衍的年華 提交于 2019-12-04 05:36:43
As titled, I cannot seem to be able to dim the background of the custom dialog box I have made. Countless solutions online mention the last 3 lines of code in the first snippet below, this has made no impact on the UI of the dialog box. See the following code: Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog); TextView textView = (TextView) dialog.findViewById(R.id.textView); textView.setText("Custom Text Example"); dialog.show(); WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes(

List View in Fragment not working

荒凉一梦 提交于 2019-12-04 05:22:26
问题 Heres my fragment code : public class LeftFragment extends ListFragment { ArrayList<String> data; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.left_fragment, container, false); data = new ArrayList<String>(); data.add("1. dell"); data.add("2. samsung"); data.add("3. apple"); data.add("4. hp"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,

Android parse Plist file

六眼飞鱼酱① 提交于 2019-12-04 03:47:05
Hello Im trying to parse an plist file that contains array of dict's. Im trying to do this using xmlwise . The content of the plistfile is here So far I only have this in my activity and im getting the content of the plistfile, but how to parse the content into an arraylist? Map<String, Object> properties = null; try { InputStream inputStream = getResources().openRawResource(R.raw.first_5); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line); }

What is XML property xmlns:app?

梦想的初衷 提交于 2019-12-04 03:03:45
问题 XML is working good with: xmlns:app="http://schemas.android.com/apk/res-auto" but can't see max characters with xmlns:app="http://schemas.android.com/tools" which is completed by Android Studio auto . Here is my XML: <com.rengwuxian.materialedittext.MaterialEditText android:id="@+id/remark_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" app:met_maxCharacters="20" app:met_baseColor="@color/black"