java - Android - Unable to create new Intent which triggered from OptionMenu -


i new android development , stuck when trying develop simple app based on this tutorial

what want start new intent when user click on button via setting menu (of said app).

this segment of code:

mainactivity.java

here getting error set_time_request_id constant has not been declared anywhere in code. should declare it, not sure type of constant , value should assign with.

*** rest of code ****  private void settime() {       intent = new intent(getbasecontext(), countdownsettime.class);       startactivityforresult(i, set_time_request_id);     }  *** rest of code *** 

countdownsettime.java

the error getting part are; context , secondsset cannot resolved variable. again, not sure this. should declare variable called secondsset? if yes, type?

*** rest of code ***  public void oncreate(bundle savedinstancestate) {       super.oncreate(savedinstancestate);       setcontentview(r.layout.set_time);        context = this.getapplicationcontext(); // error here.       spinner spinner = (spinner) findviewbyid(r.id.spinner);       arraylist<integer> spinnerlist = new arraylist<integer>();        (int = min; <= max; i++) {         spinnerlist.add(i);       }        arrayadapter<integer> adapter = new arrayadapter<integer>(context,               android.r.layout.simple_spinner_item, spinnerlist);        adapter.setdropdownviewresource(               android.r.layout.simple_spinner_dropdown_item);        spinner.setadapter(adapter);       spinner.setonitemselectedlistener(new onitemselectedlistener() {         public void onitemselected(adapterview<?> parent,           view view, int pos, long id) {           secondsset = (integer)parent.getitematposition(pos); // error here         }         public void onnothingselected(adapterview<?> parent) {           // nothing.         }     }); }  *** rest of code *** 

manifest.xml

i absolutely clueless this. not sure how register new intent.

<application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.gelliesmedia.countdown.mainactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity         android:name="com.gelliesmedia.countdown.countdownsettime"         android:label="@string/app_name"         android:parentactivityname="com.gelliesmedia.countdown.mainactivity" >         <meta-data              android:name="android.support.parent_activity"              android:value="com.gelliesmedia.countdown.mainactivity" />     </activity> </application> 

could point me right direction?

i have read tutorial give link. tutorial doesn't give full code. according see variables mention must defined.

for set_time_request_id add @ beginning that

private static final int set_time_request_id = 1; 

because onactivityresult(int, int, intent) id internal identification. put 1 can put number. id when activity closes can fetch result.

so yes have define it.

same secondsset.

the type seems integer because parent.getitematpostion cast integer. used not defined. seems me global variable. ones put @ top of class.

so yes have define :-)

and same context. used not declared. seems tutorial use declares these variable globally.

edit

the manifest file tells system intent (activity) exist.

you should have thing that

<activity     android:name="com.gelliesmedia.countdown.countdownsettime"> </activity>  

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -