I'm very new to programming, just a bit of a weekend hobby. I'm wanting to create an app that is like an interactive calendar, basically it works like this..
The main Activity displays a calendar where you can tap on a date and a new Activity will be launched. On this new Activity you can select a category for your item and an ImageButton will be added to the calendar date upon selecting the category. Once the button has been placed you can then tap on it and set extra information (alarm,place,details etc)
I have gotten as far as to do all the calendar layout, buttons to different activities and dynamically adding the calendar date ImageButton, but I have hit a dead end on how to save the data (the ImageButton) added by the user; 'Clicking button1 in activityB(e.g sport date) creates a dynamic image button of a baseball in activityA(calendar) layout, so my question is how do I save that data permanently(can be deleted by user).
I have spent the last few days reading over Onpause, onSaveinstancestate,onConfiguration,SQL,fragments and database. But I can't make heads or tails on how to apply this, let alone to apply it to an activity object created from another activity, I'd greatly appreciate any insight.
My code for the activity with the button that creates the dynamic button:
package org.iimed.www;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import org.iimed.www.Sundayopen;
import android.widget.RelativeLayout;
import android.widget.TableLayout.LayoutParams;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
public class Penicillins extends Activity implements OnClickListener {
ImageButton addmed,ab;
RelativeLayout ll;
public void onCreate(Bundle SavedInstanceState){
super.onCreate(SavedInstanceState);
setContentView(R.layout.penicillin);
addmed =( ImageButton)findViewById(R.id.addmed);
addmed.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()){
case R.id.addmed:
setContentView(R.layout.sundayopen);
ll =(RelativeLayout) findViewById(R.id.sundayopen);
android.widget.LinearLayout.LayoutParams b = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
int i = 0;
ab = new ImageButton(this);
ab.setImageResource(R.drawable.adaba);
ab.setBackgroundColor(Color.TRANSPARENT);
ab.setLayoutParams(b);
ab.setId(i) ;
ab.getId();
ab.setTag(1);
ll.addView(ab);
}
}
}
My code for the activity the button appears in:
package org.iimed.www;
import java.util.ArrayList;
import android.R.string;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.view.View.OnClickListener;
public class Sundayopen extends Activity implements OnClickListener {
public static final Integer [] aba = {R.id.aba};
ImageButton ab;
public void onCreate(Bundle SavedInstanceState) {
super.onCreate(SavedInstanceState);
setContentView(R.layout.sundayopen);
ImageButton hb1 = (ImageButton) findViewById(R.id.homebutton1);
RelativeLayout ll =(RelativeLayout) findViewById(R.id.sundayopen);
ImageButton sbc = (ImageButton) findViewById(R.id.satlidopen);
ImageButton abb = (ImageButton) findViewById(R.id.abbutton);
sbc.setOnClickListener(this);
hb1.setOnClickListener(this);
abb.setOnClickListener(this);
}
public void onClick(View v){
switch (v.getId()) {
case R.id.homebutton1:
startActivity(new Intent(this, MainActivity.class));
break;
case R.id.satlidopen:
MediaPlayer media = MediaPlayer.create(Sundayopen.this, R.raw.openlid);
media.start();
startActivity(new Intent(this,Iimedja.class));
break;
case R.id.abbutton:
startActivity(new Intent(this, ImageTextListViewActivity.class));
}
}
}