I had a good ListView, but now I added Fragments, now my Code doesn't work in the onCreateMenu...
How to make my ListView back?
So here's my code:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View myFragmentView;
Bundle b = getArguments();
int Nr = b.getInt(ARG_SECTION_NUMBER);
if (Nr == 0) {
myFragmentView = inflater.inflate(R.layout.layoutexample, container, false);
} else {
myFragmentView = inflater.inflate(R.layout.another_layout_example, container, false);
}
return myFragmentView;
}
I don't understand, where to put my code (for example if I want a ListView)!
Can I use something similar to the inflater?
Please help, as a beginner I only understand half of the information, Google Developers gives me...
This is my ListView:
public class Home extends ListActivity {
ListView listView;
static final String[] Liste = {"a", "b", "c"};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("CalcPlus");
listView = getListView();
listView.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.text, Liste) {
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
String item = getItem(position);
TextView subTitleView = (TextView) view.findViewById(R.id.subtitle);
subTitleView.setText("Subtitle of " + item);
return view;
}
});
}
}
That's the list_item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=""
android:textAllCaps="false"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=""
android:textAllCaps="false"
android:textSize="16dp"
android:textStyle="normal" />
</LinearLayout>
Here's the example.xml (they both look the same):
<?xml version="1.0" encoding="utf-8"?>
<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" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
</RelativeLayout>
After having inflated your view, you can add :
ListView listView = myFragmentView.findViewById(android.R.id.list);
listView.setAdapter(....);
Edit : I didn't know the id you set to your ListView. Replace android.R.id.list by R.id.listView1
Related
I'm trying to create listview programatically in android.
My goal is to create a dynamic view where if i click one button it will change the content inside the layout from listview into another view or vice versa.
Everything seems good i successfully put the listview inside a linear layout from the java file and i did that by creating a custom layout for the cell.
The problem is it shows the listview but it does not add the cell.
I know that it place the listview because the background become green when I run it but it does not show up the cell of the listview.
Am i missing something?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#color/colorPrimary">
<TextView
android:id="#+id/listContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"/>
</RelativeLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity {
LinearLayout mainView,sideView;
ListView notelist;
String[] Names = {"great","good","average","great","good","average"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainView = (LinearLayout)findViewById(R.id.mainView);
notelist = new ListView(this);
notelist.setBackgroundColor(Color.GREEN);
CustomAdapter customAdapter = new CustomAdapter();
notelist.setAdapter(customAdapter);
notelist.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
mainView.addView(notelist);
}
class CustomAdapter extends BaseAdapter{
#Override
public int getCount() {
return Names.length;
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = getLayoutInflater().inflate(R.layout.list_vertical,null);
TextView contentText = (TextView) view.findViewById(R.id.listContent);
contentText.setText(Names[position]);
return null;
}
}
}
main xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<LinearLayout
android:id="#+id/sideView"
android:layout_weight=".20"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageButton
android:id="#+id/oneBtn"
android:layout_width="#dimen/ButtonSize"
android:layout_height="#dimen/ButtonSize"
android:background="#android:color/transparent"
android:src="#drawable/noct"
/>
<ImageButton
android:id="#+id/twoBtn"
android:layout_width="#dimen/ButtonSize"
android:layout_height="#dimen/ButtonSize"
android:background="#android:color/transparent"
android:src="#drawable/note"
/>
<ImageButton
android:id="#+id/threeBtn"
android:layout_width="#dimen/ButtonSize"
android:layout_height="#dimen/ButtonSize"
android:background="#android:color/transparent"
android:src="#drawable/journal"
/>
<ImageButton
android:id="#+id/fourBtn"
android:layout_width="#dimen/ButtonSize"
android:layout_height="#dimen/ButtonSize"
android:background="#android:color/transparent"
android:src="#drawable/mic"/>
<ImageButton
android:id="#+id/fiveBtn"
android:layout_width="#dimen/ButtonSize"
android:layout_height="#dimen/ButtonSize"
android:background="#android:color/transparent"
android:src="#drawable/add"
/>
<ImageButton
android:id="#+id/sixBtn"
android:layout_width="#dimen/ButtonSize"
android:layout_height="#dimen/ButtonSize"
android:background="#android:color/transparent"
android:src="#drawable/pencil"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/mainView"
android:layout_weight=".80"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
Do not return null in getView
public View getView(int position, View convertView, ViewGroup parent) {
View view = getLayoutInflater().inflate(R.layout.list_vertical,null);
TextView contentText = (TextView) view.findViewById(R.id.listContent);
contentText.setText(Names[position]);
return view;
}
public View getView(int position, View convertView, ViewGroup parent) {
convertView = getLayoutInflater().inflate(R.layout.list_vertical,null);
TextView contentText = (TextView) convertView.findViewById(R.id.listContent);
contentText.setText(Names[position]);
return convertView;
}
I'm trying to put a list view inside a fragment. I made tries and here is what I got (My app is working, but the list view simply doesn't appear.):
The Fragment I want the list in:
public class Trechos extends Fragment {
ListView list;
#Override
//Método para inflar o layout
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState){
//Variável view to tipo View infla o layout a ser usado
View view = inflater.inflate(R.layout.trechos, container, false);
Classe classe = new Classe(getActivity());
list = (ListView) view.findViewById(R.id.list);
list.setAdapter(classe);
//retorna a variável view
return view;
}
}
The xml for the fragment:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
<ListView
android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="adasdasds">
</ListView>
</LinearLayout>
The custom adapter I created to insert the informations:
public class Classe extends ArrayAdapter<String> {
private final Activity context;
private String [] trechos = {"a", "b"};
private int [] posicao = {1,2};
public Classe(Activity context) {
super(context, R.layout.row_layout);
this.context = context;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rootView = inflater.inflate(R.layout.row_layout, null, true);
TextView txtPosicao = (TextView) rootView.findViewById(R.id.posicao);
TextView txtTrecho = (TextView) rootView.findViewById(R.id.trechos);
txtPosicao.setText(posicao[position]);
txtTrecho.setText(trechos[position]);
return rootView;
}
}
And the xml for the custom rows:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<TextView
android:textSize="20sp"
android:textStyle="bold"
android:padding="5dp"
android:id="#+id/posicao"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:textStyle="italic"
android:textSize="20sp"
android:padding="5dp"
android:id="#+id/trechos"
android:layout_width="match_parent"
android:layout_height="50dp" />
</TableRow>
</TableLayout>
I am attempting to display a listview in a fragment. However, nothing is displaying and the logging seems correct. The screen is completely blank. I thought the cause was an error in inflating the view, but I just have no clue. I have researched SO and other websites with no luck.
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.v("FeaturesFragment", "FeaturesFragment");
//View v = inflater.inflate(R.layout.carfeatures_list, container, false);
//View v = inflater.inflate(R.layout.features_list_item, container, false);
View v = inflater.inflate(R.layout.features_list_item, null);
//View v = inflater.inflate(R.layout.carfeatures_list,null);
ListView lv = (ListView) v.findViewById(android.R.id.list);
Log.v("ListView lv1-features", lv.toString());
adapter = new CustomListViewAdapter(carFeaturesList, R.layout.carfeatures_list, super.getActivity());
//adapter = new CustomListViewAdapter(carFeaturesList, R.layout.features_list_item, super.getActivity());
lv.setAdapter(adapter);
Log.v("ListView lv2-features", lv.toString());
adapter.notifyDataSetChanged();
//Listview on item click listener
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//Gets values from selected ListItem
String car_features = ((TextView) view.findViewById(R.id.car_features)).getText().toString();
//Log.v("onCreate-car_features", car_features.toString());
String carfeatures_id = ((TextView) view.findViewById(R.id.carfeatures_id)).getText().toString();
//Log.v("onCreate-carfeatures_id", carfeatures_id.toString());
String model_id = ((TextView) view.findViewById(R.id.model_id)).getText().toString();
//Log.v("onCreate-model_id", model_id.toString());
String carfeatures_desc = ((TextView) view.findViewById(R.id.carfeatures_desc)).getText().toString();
//Log.v("onCreate-carfeats_desc", carfeatures_desc.toString());
Boolean b = Boolean.valueOf(TAG_CARID);
if (b == true) {
view.setBackgroundColor(Color.GREEN);
}
//Colors the selected listview item
if (previouslySelectedItem != null) {
previouslySelectedItem.setBackgroundColor(Color.TRANSPARENT);
//Log.v("previouslySelectedItem", "!=null");
//Log.v("position", Integer.toString(position));
}
view.setBackgroundColor(Color.GREEN);
//Log.v("position", Integer.toString(position));
//Log.v("outofif-view", view.toString());
previouslySelectedItem = view;
}
});
//Calls async task to get json
new GetCarFeatures().execute();
Log.v("return called-Features", "return called");
Log.v("v", v.toString());
return v;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
CarFeatures item = getItem(position);
//Log.v("CarFeaturesitem", Integer.toString(position));
if (convertView == null) {
holder = new ViewHolder();
LayoutInflater mInflater = LayoutInflater.from(getContext());
convertView = mInflater.inflate(R.layout.carfeatures_list, null);
//convertView = mInflater.inflate(R.layout.features_list_item, null);
Log.v("getView", "getView");
Log.v("View convertView", convertView.toString());
Log.v("ViewGroup parent", parent.toString());
holder.carfeatures_id = (TextView) convertView.findViewById(R.id.carfeatures_id);
//Log.v("if-holder.carfeat_id", holder.carfeatures_id.toString());
holder.model_id = (TextView) convertView.findViewById(R.id.model_id);
//Log.v("if-holder.model_id", holder.model_id.toString());
holder.carfeatures_desc = (TextView) convertView.findViewById(R.id.carfeatures_desc);
//Log.v("if-holder.carfeat_id", holder.carfeatures_desc.toString());
convertView.setTag(holder);
//Log.v("if-convertView", convertView.toString());
//Log.v("if-holder", holder.toString());
} else {
holder = (ViewHolder) convertView.getTag();
//Log.v("else-convertView", convertView.toString());
//Log.v("else-holder", holder.toString());
}
holder.carfeatures_id.setText(item.carfeatures);
//Log.v("holder.carfeatures_id", holder.carfeatures_id.toString());
holder.model_id.setText(item.modelid);
//Log.v("holder.model_id", holder.model_id.toString());
holder.carfeatures_desc.setText(item.carfeaturesdesc);
//Log.v("holder.carfeatures_desc", holder.carfeatures_desc.toString());
adapter.getItemId(position);
//Log.v("getitemid1", Long.toString(adapter.getItemId(position)));
Log.v("convertView", convertView.toString());
return convertView;
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#android:id/list"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:choiceMode="singleChoice"
android:layout_gravity="center_horizontal|top"
android:layout_alignParentStart="true" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/car_features"
android:layout_below="#+id/model_id"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/carfeatures_id"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/car_features" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/model_id"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/carfeatures_desc"
android:layout_above="#+id/car_features"
android:layout_alignParentStart="true" />
</RelativeLayout>
I might be wrong, but it seems that in your
public View getView(int position, View convertView, ViewGroup parent)
you are trying to inflate this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/car_features"
android:layout_below="#+id/model_id"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/carfeatures_id"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/car_features" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/model_id"
android:layout_below="#+id/header"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/carfeatures_desc"
android:layout_above="#+id/car_features"
android:layout_alignParentStart="true" />
<ListView
android:id="#android:id/list"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:choiceMode="singleChoice"
android:layout_gravity="center_horizontal|top"
android:layout_alignParentStart="true" />
</RelativeLayout>
which will not work, because you need to inflate an item of the list (not the layout containig the list), an item, which you will fill with your data from array. I would suggest you to create a layout for that item, name it list_item.xml and inflate it.
Oh, and in case you have this item, please show it to us
I was trying to change the color of a text view in a list fragment after onclick button.
Im using an add button(addBtn) to add the contents to list dynamically an another button(clrBtn) to change the color of the textview which is already added to the list
Im getting a nullPointerException. Can you please let me know where am i going wrong
Below is my code :
public class FragmentOne extends ListFragment {
String[] order = new String[] {};
int[] qty;
public FragmentOne(){}
/** Declaring an ArrayAdapter to set items to ListView */
SimpleAdapter adapter1;
// Keys used in Hashmap
String[] from = { "num","itm","price","qty" };
// Ids of views in listview_layout
int[] to = { R.id.num,R.id.itm,R.id.price,R.id.qty};
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView;
Button addBtn,clrBtn;
rootView = inflater.inflate(R.layout.fragment_1, container, false);
addBtn = (Button) rootView.findViewById(R.id.btnAdd);
clrBtn = (Button) rootView.findViewById(R.id.btnClear);
addBtn.setOnClickListener (new OnClickListener() {
#Override
public void onClick(View v) {
//ListFragment fragment=new FragmentProdQtyPrice();
Fragment fragment=new FragmentExListView();
Bundle bundle = new Bundle();
bundle.putInt("fragmentId", 1);
fragment.setArguments(bundle);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
}
});
clrBtn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
/*MainActivity.aList.clear();
adapter1=new SimpleAdapter(getActivity().getBaseContext(), MainActivity.aList, R.layout.listview_layout, from, to);
setListAdapter(adapter1);*/
LinearLayout tv=(LinearLayout)arg0.findViewById(R.id.listtest);
tv.setBackgroundColor(Color.parseColor("#FF0000"));
}
});
adapter1=new SimpleAdapter(getActivity().getBaseContext(), MainActivity.aList, R.layout.listview_layout, from, to);
setListAdapter(adapter1);
return rootView;
}
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
String prompt =
"clicked item: " + getListView().getItemAtPosition(position).toString();
Toast.makeText(getActivity(),prompt , Toast.LENGTH_SHORT).show();
}}
Edited:
My Layout files :
Fragment_1.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/LinearLayout02"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<Button
android:id="#+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="add" />
<Button
android:id="#+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Clr" />
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/LinearLayout02" />
<TextView
android:id="#android:id/empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/LinearLayout02"
android:gravity="center_horizontal"
android:text="#string/txtEmpty" />
</RelativeLayout>
listview_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/listtest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/itm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp" />
<TextView
android:id="#+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp" />
</LinearLayout>
<TextView
android:id="#+id/qty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingTop="10dp" android:textSize="15sp" /></LinearLayout>
Try this Solution:
You are looking child view in Button element. Button element doesn't have any child element.
clrBtn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
LayoutInflater inflater = LayoutInflater.from(FragmentOne.this.getActivity().getApplicationContext());
View root = inflater.inflate(R.layout.listview_layout,null);
LinearLayout tv=(LinearLayout)root.findViewById(R.id.listtest);
tv.setBackgroundColor(Color.parseColor("#FF0000"));
}
});
I am trying to implete listview into fragment.But my app is crashing here is my fragment code
public class ConversationFragment extends Fragment {
public View rootView=null;
private ListView lv;
private ArrayList<String> strArr;
private ArrayAdapter<String> adapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String name = getArguments().getString("name");
rootView = inflater.inflate(R.layout.fragment_conversation, container, false);
TextView username=(TextView)rootView.findViewById(R.id.user_name);
username.setText(name);
strArr=new ArrayList<String>();
adapter=new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1,strArr);
lv.setAdapter(adapter);
rootView.findViewById(R.id.get_from_user).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (v.getId() == R.id.get_from_user) {
getFromUser(v);
}
}
});
return rootView;
}
This is the fragment layout xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#878787" >
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="dfgdfgdf"
android:textSize="20dp"
android:layout_centerInParent="true"
android:id="#+id/user_name"/>
<EditText
android:id="#+id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="#+id/get_from_user"
android:text="Gönder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
/>
<ListView
android:id="#+id/message_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
And there is the logcat:http://prntscr.com/4a5svo
How can I fix it ? What do you suggest ?
lv value is not set. add code of findviewbyid on lv you should be good
initialize your Listview lv like you did for Textview and make sure your strArr Not empty
TextView username=(TextView)rootView.findViewById(R.id.user_name);