As the question dictates, i need to display records from database, different record for each child.ie, child 1= record 1 data. child 2 =record 2 data.so and so. i came up with t
It should be like below. Also post the stack trace so that we can help you further
public class DisplayActivity extends ListActivity {
DBAdapter db;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_cursor);
db=new DBAdapter(this);
Button viewbutton=(Button)findViewById(R.id.button2);
viewbutton.setOnClickListener(new OnClickListener()
{
@override
public void onClick(View v)
{
// do something
}
});
}
Edit:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ListView
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_width="fill_parent"
android:id="@+id/lv" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Button" />
</RelativeLayout>
MainActivity.java
public class MainActivity extends Activity {
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
lv= (ListView) findViewById(R.id.lv);
b.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// set your adapter to listview here
}
});
}
}