android-layout

Android: Multiple view children for custom view with existing layout

╄→尐↘猪︶ㄣ 提交于 2020-07-16 16:20:41
问题 I have to build a more complex custom view in Android. The final layout should look like this: <RelativeLayout> <SomeView /> <SomeOtherView /> <!-- maybe more layout stuff here later --> <LinearLayout> <!-- the children --> </LinearLayout> </RelativeLayout> However, in the XML files I just want do define this (without defining SomeView, SomeOtherView etc.): <MyCustomView> <!-- the children --> </MyCustomView> Is this possible in Android, and if yes: What would be the cleanest way to do it?

So I created a class to change layouts according to a construcotr but it wont work?

梦想与她 提交于 2020-07-16 08:25:23
问题 SO i have to classes CollegeSearch.kt and CollegeSwitcher.kt The first one make use of a recyclerview to put up a list for people to use and select a country. When they tap on it, I want the layout to switch by switching the class. here is the CollegeSearch.kt class: class CollegeSearch : AppCompatActivity() { var college_DU:MutableList<String> = ArrayList() var displayList:MutableList<String> = ArrayList() override fun onCreate(savedInstanceState: Bundle1?) { super.onCreate

How to search for a String in Android's Strings.xml?

拥有回忆 提交于 2020-07-10 10:27:25
问题 I tried this answer: How to search content of strings stored in XML file?: companion object { val TAG: String = "EffectsDescription" fun fromStringsXml(string: String, context: Context): String { val ss = string.toLowerCase().replace(" ", "_"); Log.d(TAG, "gonna search for " + ss); val s = searchForString(ss, context); Log.d(TAG, "found: " + s); return s ?: "ERROR" } private fun searchForString(message: String, context: Context): String? { return try { val resId: Int = context.resources

Why using View Binding is changing the layout?

情到浓时终转凉″ 提交于 2020-07-09 14:32:40
问题 Actual Code: My Main Activity: class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) val rollButton = binding.rollButton rollButton.setOnClickListener { rollDice() } setContentView(binding.root) } private fun rollDice() { val randomDiceRoll = Random.nextInt(6) + 1 Toast.makeText(this, randomDiceRoll.toString(),

How to add a back button to the fragment in the action bar of an opened activity?

♀尐吖头ヾ 提交于 2020-07-09 11:54:09
问题 I have a HomeActivity that implements NavigationView without ToolBar (with ActionBar). In this activity I implement the onNavigationItemSelected that I use to navigate to SettingsFragment : protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_menu); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } // more code

facing below error “tools:node” associated with an element type “uses-permission” is not bound

自古美人都是妖i 提交于 2020-07-08 13:09:38
问题 We are facing issue related manifest marge after changed in merged file error is: "The prefix "tools" for attribute "tools:node" associated with an element type "uses-permission" is not bound." Why this error occur and how to solve this ? We are trying to add line in application tag for override but not solve ,searching more all gives answer to add line in top for tools added this but also not solve. After replace manifest with old files but also giving same error. <?xml version="1.0"

facing below error “tools:node” associated with an element type “uses-permission” is not bound

十年热恋 提交于 2020-07-08 13:08:52
问题 We are facing issue related manifest marge after changed in merged file error is: "The prefix "tools" for attribute "tools:node" associated with an element type "uses-permission" is not bound." Why this error occur and how to solve this ? We are trying to add line in application tag for override but not solve ,searching more all gives answer to add line in top for tools added this but also not solve. After replace manifest with old files but also giving same error. <?xml version="1.0"

How can I set OnClickListener to two buttons in RecyclerView?

家住魔仙堡 提交于 2020-07-06 12:02:37
问题 In my android app I have one activity to show a RecyclerView in which each row is composed by a TextView and 2 buttons. Just like that: Well, following many explanations of internet I have made this Adapter: public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ViewHolder> { private LayoutInflater layoutInflater; protected Vector<List> lists; public ListAdapter(Context context, Vector lists) { layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER

Android: Is it possible to use string/enum in drawable selector?

笑着哭i 提交于 2020-07-05 05:26:46
问题 Questions Q1 : Has anyone managed to get custom string/enum attribute working in xml selectors? I got a boolean attribute working by following [1], but not a string attribute. EDIT: Thanks for answers. Currently android supports only boolean selectors. See accepted answer for the reason. I'm planning to implement a little complex custom button, whose appearance depends on two variables. Other will be a boolean attribute (true or false) and another category-like attribute (has many different

Android: Is it possible to use string/enum in drawable selector?

微笑、不失礼 提交于 2020-07-05 05:26:11
问题 Questions Q1 : Has anyone managed to get custom string/enum attribute working in xml selectors? I got a boolean attribute working by following [1], but not a string attribute. EDIT: Thanks for answers. Currently android supports only boolean selectors. See accepted answer for the reason. I'm planning to implement a little complex custom button, whose appearance depends on two variables. Other will be a boolean attribute (true or false) and another category-like attribute (has many different