I am trying to put ListView
and TextView
in same layout and I managed to do so but on executing the application I got some errors.
Below is the xml code
`
<ListView
android:id="@+id/lvCourses"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="40" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="60"
android:orientation="vertical" >
<TextView
android:id="@+id/tvHOD"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:text="Output here" />
</LinearLayout>
</LinearLayout>
Here is the JAVA code
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.teacher);
Courses = (ListView) findViewById(R.id.lvCourses);
Output = (TextView) findViewById(R.id.tvHOD);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, android.R.id.text1, Names);
Courses.setAdapter(adapter);
Courses.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Output.setText(HOD[arg2]);
}
Logcat says the error is in onCreate function but on seeing code I can't understand everything looks fine. Need help please.