I have created a listview called popuplistfragment.java and list_view.xml.I have added textview in xml file but I dont know where to add code to change the textview in the listview.
import android.app.ListFragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
public class PopupListFragment extends ListFragment implements OnItemClickListener {
TextView textview;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.list_item, container, false);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.quotes, android.R.layout.simple_list_item_1);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
//Toast.makeText(getActivity(), "Item: " + position, Toast.LENGTH_SHORT).show();
String item = (String) parent.getItemAtPosition(position);
Log.v("check", "item is clicked");
Intent myIntent = new Intent(getActivity(), SwipeViews.class);
myIntent.putExtra("key", item);
myIntent.putExtra("index", position);
startActivity(myIntent);
}
}
And this is the list_view.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeight"
android:background="@drawable/back_listview">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:longClickable="false"
>
</ListView>
<TextView
android:id="@+id/text1"
android:textColor="#e15258"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:maxLines="1"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>