0
我正在建設一個節日應用程序,在那裏你可以得到特定音樂會的提醒。我不知道如何做到這一點,所以我真的希望有人能幫助我。我已經制作了開關和佈局。我只需要開關來激活警報。使開關設置一個預定義的鬧鐘
下面是我的一些代碼:
package com.example.kjart.borkmusik;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
public class MainActivity extends ActionBarActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.Webview);
myWebView.loadUrl("http://www.borkhavnmusikfestival.dk/");
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case R.id.action_settings:
Intent intent = new Intent();
Intent launchNewIntent = new Intent(MainActivity.this,Pamindelse.class);
startActivityForResult(launchNewIntent, 0);
return true;
}
return false;
}
}
package com.example.kjart.borkmusik;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class Pamindelse extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pamindelse);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_pamindelse, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.layout.activity_pamindelse) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
package com.example.kjart.borkmusik;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class Pamindelse extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pamindelse);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_pamindelse, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.layout.activity_pamindelse) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
嗯,也許愚蠢qestion但我應該在哪裏把這個代碼! //當需要提醒用戶時,AlarmReceiver將被調用。 //並使用putExtra您可以保存音樂會數據,例如音樂會的名字。 Intent intent = new Intent(mContext,AlarmReceiver.class); 等等:) 和hwo我做一個開關激活BroadcastReciver? :-) 謝謝。 –
你只是使用webview來查看內容,或者你會使用某種本地組件,比如List? – heloisasim
我使用本地組件!是的,這是一個列表! =新班。佈局等等:-) –