[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572944-105":53,"doc-detail-572944-en":126},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":119,"head_meta":121,"extra_data":123,"updated_unix":125},105,"en","code-cheat-sheet-xml-and-android-starter-code","Code Cheat Sheet - XML and Android Starter Code","","Code cheat sheet covering Android essentials with XML starter code and practical UI wiring. Includes how to connect a View to actions using android:onClick, implement the corresponding Java method, and navigate to a new screen via Intent and startActivity. Provides examples for finding views by ID, extracting values from EditText as String and parsing to int, updating TextView/EditText contents, setting images with setImageResource, disabling views, generating random numbers, and displaying an on-screen Toast message.",{"@graph":63,"@context":118},[64,80,101],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":51,"@type":70,"position":76},"https://docshare.wps.com/template/general/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/code-cheat-sheet-xml-and-android-starter-code/572944/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/code-cheat-sheet-xml-and-android-starter-code/572944.png","ImageObject",442,249,{"name":88,"@type":89},"Elsa","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-17","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":73},"InteractionCounter",{"@type":100},"ViewAction",{"@type":102,"mainEntity":103},"FAQPage",[104,110,114],{"name":105,"@type":106,"acceptedAnswer":107},"How do you connect an XML button click to a Java method?","Question",{"text":108,"@type":109},"Use android:onClick in XML with the action name, then implement a matching public method in Java with the same name signature.","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"How can you navigate to another screen in Android from a button click?",{"text":113,"@type":109},"Create an Intent with the current context and target Activity class, then call startActivity(i).",{"name":115,"@type":106,"acceptedAnswer":116},"How do you read user input from an EditText and convert it to an int?",{"text":117,"@type":109},"Get the text with e.getText().toString(), then convert using Integer.parseInt(word) to obtain an int.","https://schema.org",{"og:url":78,"og:type":120,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":122,"canonical":78},"index,follow",{"doc_id":124,"site_id":56},572944,1792251406,{"code":4,"msg":5,"data":127},{"doc_id":124,"user_id":128,"nickname":88,"user_avatar":129,"doc_module":9,"category_id":50,"category_name":51,"doc_title":59,"doc_description":61,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":73,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":9,"language":135,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":61,"update_tm":139,"read_time":4},137455077381,"https://ap-avatar.wpscdn.com/davatar_994ba38a5ba835b3df7d355c54d3ed8d","Code cheat sheet  \nXML Starter Code:  \n\u003C?xml version=\"1.0\" encoding=\"utf-8\"?>  \n\u003CLinearLayout xmlns:android=\"[http://schemas.android.com/apk/res/android](http://schemas.android.com/apk/res/android)\"  \nandroid:layout_width=\"match_parent\"  \nandroid:layout_height=\"match_parent\"  \nandroid:orientation= \"vertical\" >\u003C/LinearLayout>  \nWorking Buttons:  \n􀁸 In XML to connect View to action:  \nandroid:onClick= \"subtract\"  \n􀁸 In Java, to code action: (method name matches onClick)  \npublic void subtract(View view){  \n}  \nTo move to a new screen: (put in the correct JAVA class name)  \nIntent i = new Intent(this , InstructionsActivity.class);  \nstartActivity(i);  \nTo “find” the view so you can change it: (remember that Views need ids first)  \nTextView t = (TextView) findViewById( [R.id.](R.id.txt)[txt](R.id.txt));  \nImageView i = (ImageView) findViewById( [R.id.](R.id.pic)[pic](R.id.pic));  \nEditText e = (EditText) findViewById( [R.id.](R.id.write)[write](R.id.write));  \nTo get String out an EditText:  \nString word = e.getText() .toString(); To get an int out of an EditText:  \nint num = Integer.parseInt(word);  \nTo change an EditText or TextView:  \nt.setText(word);  \nt.setText(\"subtract\");  \nt.setText(num+ \" \"+rNum);  \nTo change an Image or ImageButton:  \ni.setImageResource(R.drawable.hp2);  \nTo disable a View:  \ne.setEnabled(false);  \nTo get a random number:  \nint rNum = (int) (Math.random()*3+1);  \nTo make a toast (aka onscreen message):  \nToast.makeText(getApplicationContext(), \"Colour is Green!\" , Toast.LENGTH_SHORT) .show();","cbCaiaZ9wlPl6V2a","https://ap.wps.com/l/cbCaiaZ9wlPl6V2a","pdf",228882,"English","# XML Starter Code\n# Working Buttons and onClick\n# Screen Navigation with Intent\n# Finding Views by ID\n# Reading and Updating UI Values\n# Image and View State Changes\n# Random Numbers and Toast Messages","[{\"question\":\"How do you connect an XML button click to a Java method?\",\"answer\":\"Use android:onClick in XML with the action name, then implement a matching public method in Java with the same name signature.\"},{\"question\":\"How can you navigate to another screen in Android from a button click?\",\"answer\":\"Create an Intent with the current context and target Activity class, then call startActivity(i).\"},{\"question\":\"How do you read user input from an EditText and convert it to an int?\",\"answer\":\"Get the text with e.getText().toString(), then convert using Integer.parseInt(word) to obtain an int.\"}]","Code Cheat Sheet - XML and Android Starter Code | PDF",1791930194]