kotlin

Open Navigation Drawer from Button Click within Fragment (Kotlin)

允我心安 提交于 2020-08-02 04:56:30
问题 I have created a custom button in a Fragment and I am trying to open the Navigation Drawer in the Activity when it is clicked. The Navigation Drawer still opens ok when you swipe across, but the app just crashes when I click the button. I guess this is because I am trying to access from the Fragment, but I am at a loss.. Fragment override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Inflate the layout for this fragment val binding

Android app clean architecture: Should data layer have its own model classes?

孤街浪徒 提交于 2020-08-02 04:27:50
问题 What´s the best approach when developing an Android app and trying to follow clean architecture guidelines (but not extremely strict - cause that may be overkill for smaller projects). In my case, I am unsure which approach is the best (if there is a best one) regarding the data layer and if the data layer should operate on its own model classes or if it may operate directly on the domain layer models. Also, if the data layer should operate on its own model classes, should data sources like

Android app clean architecture: Should data layer have its own model classes?

空扰寡人 提交于 2020-08-02 04:27:05
问题 What´s the best approach when developing an Android app and trying to follow clean architecture guidelines (but not extremely strict - cause that may be overkill for smaller projects). In my case, I am unsure which approach is the best (if there is a best one) regarding the data layer and if the data layer should operate on its own model classes or if it may operate directly on the domain layer models. Also, if the data layer should operate on its own model classes, should data sources like

Android Date Time picker in one dialog

岁酱吖の 提交于 2020-08-01 05:54:11
问题 I am using material Date Time picker for my Android app. But I want to combine the Date and Time picker in one dialog. I am following this one. But I need to select the time right after the date selection. Please suggest possible way to do this one. 回答1: You can call TimePicker after DatePicker set Date. Like this.. String date_time = ""; int mYear; int mMonth; int mDay; int mHour; int mMinute; et_show_date_time = (EditText) findViewById(R.id.et_show_date_time); btn_set_date_time = (Button)

Kotlin setOnClickListener for a ListView

和自甴很熟 提交于 2020-07-31 05:36:38
问题 I have the following code: class BookListActivity : AppCompatActivity() { var array = arrayOf("Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10", "Item 11") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.book_list) val adapter = ArrayAdapter(this, R.layout.book_list_item, R.id.book_title, array) val listView : ListView = findViewById(R.id.book_list) listView.adapter = adapter } }

Kotlin setOnClickListener for a ListView

a 夏天 提交于 2020-07-31 05:35:08
问题 I have the following code: class BookListActivity : AppCompatActivity() { var array = arrayOf("Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10", "Item 11") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.book_list) val adapter = ArrayAdapter(this, R.layout.book_list_item, R.id.book_title, array) val listView : ListView = findViewById(R.id.book_list) listView.adapter = adapter } }

ratingbar does not filled the float value coming from JSON android

我怕爱的太早我们不能终老 提交于 2020-07-31 04:42:31
问题 the thing is if rating is 3.5 then ratingbar fills upto 3 star ...it doesnt filled half of the fourth star.... I dont know where im going wrong Need help thanks:Following is my code rating: <RatingBar android:numStars="5" android:id="@+id/ratingbar" android:layout_width="wrap_content" android:clickable="false" android:isIndicator="true" android:layout_height="45dp" android:focusableInTouchMode="false" android:defaultFocusHighlightEnabled="false" android:focusable="false" android

How to save pdf in scoped storage?

孤街醉人 提交于 2020-07-31 04:36:48
问题 Before the introduction of scoped storage i was using Download Manager to download pdf in my app and get the pdf from getExternalStorageDirectory , but due to scoped storage i can no longer use getExternalStorageDirectory as it is deprecated. I decided to move away from Download Manager as well as it downloads files in public directory and instead use retrofit to download pdf file. I know i can use the requiredLegacyStorage tag in Android Manifest but it wont be applicable to Android 11 so i

How to create masterKey after MasterKeys deprecated in Android

风流意气都作罢 提交于 2020-07-30 07:02:33
问题 I am using the following code to store some information encrypted in my app. val masterKey = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC) val sharedPreferences = EncryptedSharedPreferences.create( "secret_shared_prefs", masterKey, this, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM ) Since the MasterKeys class deprecated in Android, I should use the MasterKey class and but I cannot figure out what is the

How to create masterKey after MasterKeys deprecated in Android

一笑奈何 提交于 2020-07-30 06:58:41
问题 I am using the following code to store some information encrypted in my app. val masterKey = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC) val sharedPreferences = EncryptedSharedPreferences.create( "secret_shared_prefs", masterKey, this, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM ) Since the MasterKeys class deprecated in Android, I should use the MasterKey class and but I cannot figure out what is the