rosjava / android_apps

Applications built on top of the rosjava android libraries.
132 stars 112 forks source link

MapNav add activity? #56

Closed HelloEgg closed 7 years ago

HelloEgg commented 7 years ago

I'm trying to add new activity called "SecondMainActivity"

This activity does exact same function as MainActivity in MainActivity except location of RosImageView and Visualization view are changed with each other.

Apparently, I have to register SecondMainActivity in Mainfest however, I failed because "SecondMainActivity" is not in the package "com.github.rosjava.android_apps.map_nav"

Could you please help..?

The reason why I am doing this is because when I click the visualization view(small rectangle shape on right upper part, AKA mapview) the map disappears and only an arrow is shown...

So rather than fixing the source library, I chose to make new activity which I think would be more easier.

HelloEgg commented 7 years ago

I solved this by doing the following things..

  1. Made a new layout called "secimg" which is same with "main" but has changed location between visualization view and Ros Image View. and has transparent button on top of where visualization view is in main.xml

  2. In MainActivity, I added the following code: if (layout == 0){ setMainWindowResource(R.layout.main);} else{ setMainWindowResource(R.layout.secmain); }

notice that "layout" is an integer which is set as "1" on initial click of added button in layout If the button is clicked again, the "layout" variable, which is integer is set as "0" Also, in oncreate method, I added onclick method of button which changes value of "layout" and an Intent method that starts Mainactivity again, thus reloading layout(not the variable but the main layout! main.xml or secmain.xml according to "layout" integer value)

This worked for switching layouts, however, I still cannot figure out how I should add the arrows.. (the blue arrow which shows the location of robot and another arrow which is created when user long presses certain point on map and moves to that location)

***After I long pressed the map, the map simply disappears and the arrow,lasertrack(?) and else showed up.. I could not get back to map until I rebuild project. (and of course, arrow does not show up at this moment)

adamantivm commented 7 years ago

@HelloEgg thanks for sharing all this info! It will definitely be useful for others coming after you. For this kind of general "how to" question, I would suggest you use ROS Answers which is the right place for discussions. This issue tracker is more prepared for concrete identified bugs (like the addLayer one).