我现在在app上工作,我想做以下事情:
- 用户创建一个新页面(新活动和xml布局).
- 将用户的页面保存到数据库.
- 将页面添加到ListView作为项目,并在用户时启动它
将在ListView上单击它.
我在这里看到很多关于"动态创建活动"的答案,我理解这是不可能的,所以我不知道该怎么做.
用户可以创建的页面数量是无限的,因此必须动态完成.ListView中每个页面的布局都是相同的.
非常感谢你!!!
我是Android的新手,我的应用程序出错了.
我的应用做了以下事情:
1-用户可以选择从相机或图库导入图像.
2-所有图像都保存在数据库中,用户可以在另一个活动的列表视图中查看所有图像.
当我点击菜单栏图标传递到另一个活动,看到应用程序崩溃的所有图像,我在日志文件中收到以下错误:
11-06 15:16:17.199: E/AndroidRuntime(1789): FATAL EXCEPTION: main
11-06 15:16:17.199: E/AndroidRuntime(1789): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demodbimage/com.example.demodbimage.ImagesList}: java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
public class MainActivity extends ActionBarActivity {
private static int FROM_CAMERA = 1;
private static int FROM_GALLERY = 2;
ImageView background;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
background = (ImageView)findViewById(R.id.imgBackground);
DataBaseHandler db = new DataBaseHandler(this);
db.deleteAllContact();
} …Run Code Online (Sandbox Code Playgroud)