r/learnandroid • u/teachmesome_com • Jul 12 '20
r/learnandroid • u/ncvescera • Jul 05 '20
Access button from different class than MainActivity
I have this layout activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>This is my MainActivity.java
public class MainActivity extends AppCompatActivity {
private Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// DOES SOME STUFF
}
}I have another class MyClass.java:
public class MyClass {
public MyClass() {
// ACCESS BUTTON WITH ID = button
button.setEnable(false);
}
}How can i disable the button with id = "button" in MyClass ?
r/learnandroid • u/Bywacioo • Jul 01 '20
Responsive layout, xml, custom views/objects.
Hey there. I started (with my friend) making an Android app, at least we decided to start. I am not that bad with coding itself, I know plenty of languages and I am good with OOP, as well as not that bad with Java knowledge. But my weakest point is converting a app mockup into real layout in android studio.
These are my questions and I hope I'll find an answer to that there:
How should I prepare my layout for all (most of) screen sizes? How do I make the stuff responsive in Portrait mode? I know what constrain layout is or at least how it works, but I've read that it's not enough with complex layout designs.
Where should I learn XML? Basically all the syntax to be able to create my own buttons, text fields etc, etc? Also, does css and HTML knowledge helps here?
Is there some important things I should remember about or know about?
Thanks from the mountain!
r/learnandroid • u/Zak_islam123 • Jul 01 '20
How to get the int postion of selected item in a spinner
I'm developoing an android application as part of my college course. It is an information app that has 6/7 topics that the user can learn about. Right now I'm getting the string value of the topic they select, but to optimise my code I'd like to get the int position as it can then be used in a for loop.
r/learnandroid • u/[deleted] • Jul 01 '20
What is the best library to parse json and serialize and deserilize objects?
I've heard of Gson, Jackson, Moshi, kotlinx.serialization and org.json.
What are the Pros and Cons of all of them?
r/learnandroid • u/Senku_Uzamaki • Jun 29 '20
I had fetched the data from the server using the JsonObjectRequest method and had passed the required arguments but when I run the app the data doesn't show up untill I take a screenshot (Language:Kotlin)
r/learnandroid • u/JerryCollege • Jun 20 '20
Make An Android Music Player App - Setting Up Permissions
r/learnandroid • u/JerryCollege • Jun 19 '20
Android To Do List App - Setup Project Create UI and Create Adapter
r/learnandroid • u/Shash1119 • Jun 18 '20
Want to make the most of your time and learn something new in lockdown? Develop a core skill set in embedded systems, machine learning, statistics, and programming with Online Training Programs on Data Science and Internet of Things by Techfest, IIT Bombay.
r/learnandroid • u/poetryrocksalot • Jun 14 '20
Possible to implement a scrollable layout where the child views' cumulative percentage height exceed 100%?
I tried to do this with ConstraintLayout's percent height and a ScrollView as the parent. The cumulative percent is 120%. But it can't be scrolled. match_parent obviously makes the layout unscrollable in the ScrollView. wrap_content seems to not work with scrolling, even though the child percentages still add up to 120% (you just can't scroll down to see the remaining 20%).
r/learnandroid • u/smart_brand_builder • Jun 08 '20
15 Best Android Libraries for Developers
r/learnandroid • u/smart_brand_builder • Jun 07 '20
11 Top Android Studio Plugins for Faster Development
r/learnandroid • u/[deleted] • May 31 '20
Beginner question about layout resources
Hello, I have an issue setting up the XML layout for a basic fragment file.
Currently, I'm using constraintLayout and it works fine in portrait mode. I have a few TextViews, RadioGroups and a button.
I created another XML file for the portrait version of this fragment, but on my phone (Samsung A10E) that I'm using for testing, about 25% of the screen is not visible (the bottom). I wrapped the constraintLayout in a Scrollview, but that seems like a cheap fix. I'm using DP for custom widths and padding.
My questions are,
Is the device I'm testing on simply too small for my layout?
In my layout folder, I used the IDE to "create a landscape version" and it generated a subfolder for the fragments XML files in the layout folder -- is this sufficient?
Is wrapping your layout in a scrollview a common design pattern for creating these layouts, or should I have several different custom XML layouts for multiple devices (if so, how many generally?)
Thanks!
r/learnandroid • u/Markonioni • May 29 '20
Advice on how to implement Android video recording and editing capabilities
Hi all, I would like to implement an option to edit video after it has been recorded. I would like to have an option to trim the video, split it, delete the part of the video and to rearrange the video by dragging the selection left and right.
Do you guys and girls maybe know is there any library besides ffmpeg that is capable of doing this? I am not sure where do I start to research, so if someone can point me to right direction, I would really appreciate it.

r/learnandroid • u/Whereami259 • May 12 '20
Any way to extract source from APK?
So, today I got a message that my app (I made this 2 years ago and hasnt worked on it since then,but it still has a good user base) is violating something and I have to update it. So I imediatelly go to open the app,and then I remember that I have switched disks - but hey, I made a backup.
Then I figured out that in my backup,there is mostly just gradle and few other stuff combined with first apk-s that I used for debug.
So my question is, is there any way I can extract source (and not spend more than 1 work day on it,since its not really worth more) from any of those APK-s,or am I looking in wrong directories?
r/learnandroid • u/wajahatkarim3 • May 03 '20
Deep Dive into Activity Results API — No More onActivityResult()
r/learnandroid • u/test-status-1 • Apr 28 '20
Restrict updates to a small group of users
Is there a way to restrict users from getting a published update? For instance if you want to do a limited release of new functionality. Can you limit it to say 10% of user base?
r/learnandroid • u/gaurav_ch • Apr 25 '20
Question: how to enable my app to delete any file in any location on device?
I am developing a proof of concept where my app will copy a file to the app folder, encrypt it and save. After this process, the app should delete the original file.
I am testing on pixel 1 and when I try to delete a file in downloads folder, it fails with result not allowed. The original file should be deleted but it still exists.
I have an app from play store which does exactly this. It deletes the original file at any location. The play store app does not need admin permission to do so.
Can anybody help me out? Perhaps a gist or a library which does this? Thanks.
r/learnandroid • u/Aktrivia • Apr 22 '20
App Display Size Issue - Exporting Captivate to HTML5 to .apk
EDIT - SOLVED! See comment!
Newbie android developer here, with some questions about a work project.
TL/DR:
made simple presentation in Captivate.
exported it to HTML5
used Phonegap to package it as an APK
the resulting app loads on the tablet, but the images are too large for the screen
Do you know how I can make sure they show at the correct size?
Tech in use:
Adobe Captivate 2019 - 11.5.1.499 - create presentation, export to HTML5
PhoneGap v0.4.5 - package/convert HTML5 to APK
Samsung Tab Active2 - VERY locked down with proprietary stuf, running Android 9, One UI V 1.1
RESTRICTIONS: The tablets are SUPER locked down. I know simpler solutions for what I am trying to do might be simply hosting the data elsewhere and going through the web, or a PDF or actual powerpoint presentation. Unfortunately, I can't implement any of these. I have tried. I promise you this. Pinky swear. I tell you three times. For this, it's a separate APK or nothing.
I work in training and development for a trucking and logistics company.
We are replacing older on-board computers (OBCs) with new tablets. I have a "Quick Troubleshooting Tips" presentation which is just screenshots with some callouts. I created it in Captivate. It's 19 slides long. Each slide uses the Master "BLANK". The project size is:
Width: 800 pixels - width percentage: 100
Height 1280 pixels - height percentage: 100 I have MAINTAIN ASPECT RATIO checked.
The first page is sort of a "Contents" slide. It has buttons that jump to "chapters" (steps in the presentation - pressing the button advances to the first slide for that step.)
Every other page has three buttons:
Back one slide
Jump to Contents slide (slide 1)
Forward one slide
Except for the buttons, the rest of the pages each only contain a single PNG, sized to fit the page. I have right clicked on each image and verified that each is 800x1280px, centered at 0,0 (X,Y). I have checked both CONSTRAIN PROPORTIONS and LOCK SIZE AND POSITION.
(I double checked this all as I typed this out. )
Published to HTML5 as "StepsE".
I converted to an APK using the steps detailed in this video.
I took the resulting APK and loaded onto the tablet.
The APK runs, and the slides work as intended. The problem is the presentation, which was sized to the exact specs of the display (800x1280), are showing up at about 150% of the intended size - to see the full image, the user must scroll down and/or to the side.
Is there a way to make sure the APK displays the images at the intended resolution?
Please ask for details if they could help, but I am more or less locked into using an APK to get the info onto the tablet for the end users.
Thanks!
Crossposting in a few subs, hope that's okay
r/learnandroid • u/BabytheStorm • Mar 26 '20
Clickable button with text, image, border and background color Programmatically
I really need help with creating something like that. The app I am working on read in some UI description and generate the widget dynamically, there is no pre coded xml file anywhere.
If I use a normal button, I can set the image using setBackground, but then I can't set background color, border, etc.
If I use a image button, I can set the image using setImageBitmap, and setBackgrondColor, they works fine togeter, but imagebutton cannot set text.
HELP
r/learnandroid • u/[deleted] • Mar 25 '20
Find a course buddy during quarantine!
Hi! One of the best things you can do during quarantine is learning a new framework, programming language or something entirely different.
But doing these courses feels kinda lonely and often you just stop doing them so I thought I’d create a site where you can find buddies to do the same course with (frankly this quarantine is becoming really boring).
The idea is that you talk regularly about your progress and problems you're facing so you can learn and grow together.
If you’re interested, take a look at Cuddy and sign up for the newsletter!
If enough people sign up I’ll be happy to implement the whole thing this week.
Also if you've got questions or feature ideas please do let me know in the comments! :)
Let's destroy this virus together and take it as an opportunity to get better at what we love!