android implement dropdown with SearchView in activity - android

In activity I use SearchView and I want to implement dropdown when any result occurred is it possible ?? thanks in adavance.
searchActivity.java code
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.search_activity);
isSearchVisible = false;
isHomeVisible = true;
mActivity = this;
mContext = getApplicationContext();
mSearchView = (SearchView) findViewById(R.id.m_searchview);
edtFromDate = (EditText) findViewById(R.id.edt_from_date);
edtEndDate = (EditText) findViewById(R.id.edt_end_date);
btnSearchNow = (Button) findViewById(R.id.btn_search_now);
int searchPlateId = mSearchView.getContext().getResources()
.getIdentifier("android:id/search_plate", null, null);
View searchPlateView = mSearchView.findViewById(searchPlateId);
if (searchPlateView != null) {
searchPlateView.setBackgroundColor(Color.WHITE);
}
}
search_activity.xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="#color/main_background"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="#dimen/activity_horizontal_margin">
<SearchView android:id="#+id/m_searchview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:closeIcon="#drawable/close"
android:searchIcon="#drawable/search_blue"
android:padding="2dp"
android:background="#drawable/editext_background"
android:layout_marginBottom="#dimen/activity_horizontal_margin"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title_from_date"
android:textSize="20sp"
android:textColor="#color/colorAccent"
android:layout_marginBottom="15dp"/>
<EditText android:id="#+id/edt_from_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:drawableRight="#drawable/calendar"
android:paddingRight="20dp"
android:enabled="false"
style="#style/loginEditTextView"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title_end_date"
android:textSize="20sp"
android:textColor="#color/colorAccent"
android:layout_marginBottom="15dp"/>
<EditText android:id="#+id/edt_end_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:drawableRight="#drawable/calendar"
android:paddingRight="20dp"
android:enabled="false"
style="#style/loginEditTextView"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/btn_search_now"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/search_now"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
here's manifest code for manifest app
<activity android:name=".activity.SearchActivity"
android:label="#string/title_search_activity"
android:configChanges="orientation"></activity>

Related

Getting NullPointerException when adding toolbar

Getting NullPointerExceptionwhen trying to add a toolbar which is been defined in a layout file other than main design xml file. I keep getting the following error:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.v7.widget.Toolbar.findViewById(int)' on a null object reference
Here is my code
public class History_List_Details_Fragment extends Fragment {
Histroy_List_Model histroyListModel;
public History_List_Details_Fragment() {
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
histroyListModel = getArguments().getParcelable("historydetail");
String title=histroyListModel.getShared_title();
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
super.onCreate(savedInstanceState);
View rootView = inflater.inflate(R.layout.history_list_details_fragment, container, false);
Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.app_bar);
initializeListnersForToolbar(toolbar);
initializeViews(rootView);
return rootView;
}
private void initializeViews(View rootView) {
TextView titleText = (TextView) rootView.findViewById(R.id.txtTitle);
titleText.setText(histroyListModel.getShared_title());
TextView messageTExt = (TextView) rootView.findViewById(R.id.txtMessage);
titleText.setText(histroyListModel.getShared_message());
}
private void initializeListnersForToolbar(Toolbar toolbar){
((TextView) toolbar.findViewById(R.id.tool_bar_text_head)).setText(getResources().getString(R.string.friends));
((ImageView) toolbar.findViewById(R.id.tool_bar_back_arrow)).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Fragment fragment=new History_List_Fragment();
Utilities.getInstance(getActivity()).change_HomPage_Fragment(
fragment, "History_List_Fragment", getActivity());
}
});
}
}
History_List_Details_Fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title"
android:id="#+id/txtTitle"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Message"
android:id="#+id/txtMessage"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Duration"
android:id="#+id/txtDuration"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/lstMembers"></ListView>
</LinearLayout>
</LinearLayout>
How can I fix this error?
Add Toolbar in "history_list_details_fragment" with id "app_bar"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title"
android:id="#+id/txtTitle"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Message"
android:id="#+id/txtMessage"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Duration"
android:id="#+id/txtDuration"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/lstMembers"></ListView>
</LinearLayout>
The error states clearly. Inside history_list_details_fragment.xml there is no Toolbar. Try to add it.
Or more probably the Toolbar is in you Activity layout, so init it inside Activity.

LinearLayout is null inside button's onClick

I'm trying to hide a linearlayout on a button click and display another linearlayout which is in the same layout file. But the linearlayouts are null inside the onclick of the button.
The displayLayout and editLayout are null.
displayLayout = (LinearLayout) findViewById(R.id.linearLayout);
editLayout = (LinearLayout) findViewById(R.id.editLayout);
edit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
displayLayout = (LinearLayout) findViewById(R.id.linearLayout);
editLayout = (LinearLayout) findViewById(R.id.editLayout);
displayLayout.setVisibility(View.GONE); //error occurs here
editLayout.setVisibility(View.VISIBLE);
}
});
}
Here's the layout file:
<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="com.prematixsofs.taxiapp.EditUserDetails">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="fill_parent"
>
<!--Display UserDetails Layout-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/displayLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/custom_edittext"
android:gravity="center"
android:padding="8dp"
android:paddingLeft="10dp"
android:paddingRight="5dp" />
<TextView
android:id="#+id/phNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/custom_edittext"
android:gravity="center"
android:padding="8dp"
android:paddingLeft="10dp"
android:paddingRight="5dp" />
<TextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/custom_edittext"
android:gravity="center"
android:inputType="textEmailAddress"
android:padding="8dp"
android:paddingLeft="10dp"
android:paddingRight="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<Button
android:id="#+id/edit"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="#drawable/button_custom"
android:text="Edit"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<!--Edit Layout -->
<LinearLayout
android:id="#+id/editLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<EditText
android:id="#+id/editName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#drawable/custom_edittext"
android:gravity="center"
android:padding="8dp"
android:paddingLeft="10dp"
android:paddingRight="5dp" />
<EditText
android:id="#+id/editPhNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/custom_edittext"
android:gravity="center"
android:padding="8dp"
android:paddingLeft="10dp"
android:paddingRight="5dp" />
<EditText
android:id="#+id/editPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/custom_edittext"
android:gravity="center"
android:padding="8dp"
android:paddingLeft="10dp"
android:paddingRight="5dp" />
<EditText
android:id="#+id/editConfirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/custom_edittext"
android:gravity="center"
android:padding="8dp"
android:paddingLeft="10dp"
android:paddingRight="5dp" />
</LinearLayout>
Just fix your view ID in your code
displayLayout = (LinearLayout) findViewById(R.id.displayLayout);
editLayout = (LinearLayout) findViewById(R.id.editLayout);
edit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
displayLayout.setVisibility(View.GONE);
editLayout.setVisibility(View.VISIBLE);
}
});
}
error code displayLayout = (LinearLayout) findViewById(R.id.linearLayout);
right code displayLayout = (LinearLayout) findViewById(R.id.displayLayout);
you set a not exist id.

Actionbaractivity error

public class LoginActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) {
try
{
super.onCreate(savedInstanceState);
System.out.println("here");
setContentView(R.layout.activity_login);
Toolbar mToolBar = (Toolbar)findViewById(R.id.toolbar);
if(mToolBar != null)
{
setSupportActionBar(mToolBar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mToolBar.setNavigationOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//What to do on back clicked
finish();
}
}); //this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
setTitle("LOGIN");
}
catch(Exception e)
{
System.out.println(" "+e.getMessage());
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:minHeight="56dp"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:titleTextAppearance="#style/ToolbarTitle" />
<RelativeLayout
android:id="#+id/lais"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/toolbar"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:src="#drawable/ic_logo"
android:padding="10dp" >
</ImageView>
</RelativeLayout>
<ScrollView
android:id="#+id/scrollV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/lais"
android:fadingEdge="none"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="20dp"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Username"
android:textColor="#android:color/white"
android:textSize="14sp" />
<EditText
android:id="#+id/usernameField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:drawableLeft="#drawable/bg_username"
android:drawablePadding="5dp"
android:inputType="text"
android:singleLine="true" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Password"
android:textColor="#android:color/white"
android:textSize="14sp" />
<EditText
android:id="#+id/passwordField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:drawableLeft="#drawable/bg_password"
android:drawablePadding="5dp"
android:ems="10"
android:inputType="textPassword" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/submitBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:text="Submit"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I get the following error android.support.v7.internal.widget.ContentFrameLayout cannot be cast to android.support.v7.internal.widget.NativeActionModeAwareLayout. I still cannot figure out what the error is bout.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/RelativeLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:minHeight="56dp"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:titleTextAppearance="#style/ToolbarTitle" />
Try like above

app crashes when loading in android

unfortunately my app crashes when this activity is being loaded:
public class ManagerActivity extends Activity implements OnClickListener {
private TabHost th;
private EditText addpray1;
private EditText addplace1;
private EditText addtime1;
private Button addpray1Button;
private EditText removepray1;
private EditText removeplace1;
private EditText removetime1;
private Button removepray1Button;
private EditText addpray2;
private EditText addplace2;
private EditText addtime2;
private Button addpray2Button;
private EditText removepray2;
private EditText removeplace2;
private EditText removetime2;
private Button removepray2Button;
private EditText addtitlemessage;
private EditText addinfomessage;
private Button addmessagebutton;
private EditText removetitlemessage;
private Button removemessagebutton;
private EditText addtitleevent;
private EditText addinfoevent;
private Button addeventbutton;
private EditText removetitleevent;
private Button removeeventbutton;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.manager);
th = (TabHost) findViewById(R.id.tabhost);
InitTabs(th);
InitFields();
addpray1Button.setOnClickListener(this);
removepray1Button.setOnClickListener(this);
addpray2Button.setOnClickListener(this);
removepray2Button.setOnClickListener(this);
addeventbutton.setOnClickListener(this);
removeeventbutton.setOnClickListener(this);
addmessagebutton.setOnClickListener(this);
removeeventbutton.setOnClickListener(this);
}
private void InitTabs(TabHost th){
th.setup();
TabSpec specs = th.newTabSpec("tag1");
specs.setContent(R.id.tab1);
specs.setIndicator("עדכון הודעות");
th.addTab(specs);
specs = th.newTabSpec("tag2");
specs.setContent(R.id.tab2);
specs.setIndicator("עדכון אירועים");
th.addTab(specs);
specs = th.newTabSpec("tag3");
specs.setContent(R.id.tab3);
specs.setIndicator("עדכון זמני השבת");
th.addTab(specs);
specs = th.newTabSpec("tag3");
specs.setContent(R.id.tab4);
specs.setIndicator("עדכון זמני יום חול");
th.addTab(specs);
}
private void InitFields() {
// TODO Auto-generated method stub
addpray1 = (EditText) findViewById(R.id.addPray1);
addplace1 = (EditText) findViewById(R.id.place1);
addtime1 = (EditText) findViewById(R.id.time1);
addpray1Button = (Button) findViewById(R.id.addPrayButton1);
removepray1 = (EditText) findViewById(R.id.removePray1);
removeplace1 = (EditText) findViewById(R.id.time_remove1);
removetime1 = (EditText) findViewById(R.id.place_remove1);
removepray1Button = (Button) findViewById(R.id.removePrayButton1);
addpray2 = (EditText) findViewById(R.id.pray2);
addplace2 = (EditText) findViewById(R.id.place2);
addtime2 = (EditText) findViewById(R.id.time2);
addpray2Button = (Button) findViewById(R.id.addPrayButton2);
removepray2 = (EditText) findViewById(R.id.removePray2);
removeplace2 = (EditText) findViewById(R.id.place_remove2);
removetime2 = (EditText) findViewById(R.id.time_remove2);
removepray2Button = (Button) findViewById(R.id.removePrayButton2);
addtitlemessage = (EditText) findViewById(R.id.titleMessage);
addinfomessage = (EditText) findViewById(R.id.messageInfo);
addmessagebutton = (Button) findViewById(R.id.addMessageButton);
removetitlemessage = (EditText) findViewById(R.id.removeMessage);
removemessagebutton = (Button) findViewById(R.id.removeMessageButton);
addtitleevent = (EditText) findViewById(R.id.addEvent);
addinfoevent = (EditText) findViewById(R.id.eventInfo);
addeventbutton = (Button) findViewById(R.id.addEventButton);
removetitleevent = (EditText) findViewById(R.id.removeEvent);
removeeventbutton = (Button) findViewById(R.id.removeEventButton);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
and the xml file :
<?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" >
<ProgressBar
android:id="#+id/progressbar"
style="#android:style/Widget.ProgressBar.Horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TabHost
android:id="#+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/addMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת הודעה"
android:textSize="25sp" />
<EditText
android:id="#+id/titleMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/addMessage"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<EditText
android:id="#+id/messageInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/titleMessage"
android:hint="מידע"
android:lines="4"
android:scrollHorizontally="true" />
<Button
android:id="#+id/addMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/messageInfo"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/removeMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת הודעה"
android:textSize="25sp" />
<EditText
android:id="#+id/titleMessage_remove"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/removeMessage"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<Button
android:id="#+id/removeMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/titleMessage_remove"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/addEvent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת אירוע"
android:textSize="25sp" />
<EditText
android:id="#+id/titleEvent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/addEvent"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<EditText
android:id="#+id/eventInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/titleEvent"
android:hint="מידע"
android:lines="4"
android:scrollHorizontally="true" />
<Button
android:id="#+id/addEventButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/eventInfo"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/removeEvent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת אירוע"
android:textSize="25sp" />
<EditText
android:id="#+id/titleEvent_remove"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/removeEvent"
android:hint="כותרת"
android:lines="1"
android:scrollHorizontally="false" />
<Button
android:id="#+id/removeEventButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/titleEvent_remove"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/addPray1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת תפילה"
android:textSize="25sp" />
<EditText
android:id="#+id/pray1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/addPray1"
android:hint="תפילה" />
<EditText
android:id="#+id/place1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/pray1"
android:hint="מקום" />
<EditText
android:id="#+id/time1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/place1"
android:hint="שעה" />
<Button
android:id="#+id/addPrayButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/time1"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/removePray1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת תפילה"
android:textSize="25sp" />
<EditText
android:id="#+id/pray_remove1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/removePray1"
android:hint="תפילה" />
<EditText
android:id="#+id/place_remove1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/pray_remove1"
android:hint="מקום" />
<EditText
android:id="#+id/time_remove1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/place_remove1"
android:hint="שעה" />
<Button
android:id="#+id/removePrayButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/time_remove1"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/tab4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/addPray2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הוספת תפילה"
android:textSize="25sp" />
<EditText
android:id="#+id/pray2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/addPray2"
android:hint="תפילה" />
<EditText
android:id="#+id/place2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/pray2"
android:hint="מקום" />
<EditText
android:id="#+id/time2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/place2"
android:hint="שעה" />
<Button
android:id="#+id/addPrayButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/time2"
android:layout_centerInParent="true"
android:text="הוסף" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="#+id/removePray2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="הסרת תפילה"
android:textSize="25sp" />
<EditText
android:id="#+id/pray_remove2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/removePray2"
android:hint="תפילה" />
<EditText
android:id="#+id/place_remove2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/pray_remove2"
android:hint="מקום" />
<EditText
android:id="#+id/time_remove2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/place_remove2"
android:hint="שעה" />
<Button
android:id="#+id/removePrayButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/time_remove2"
android:layout_centerInParent="true"
android:text="הסר" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
i guess it's because i'm loading a lot of views...
I'm also wanna to add a progress bar that works while the layout is loading until its done.
how can i fix that?
thanks :)

Android setText ar the Master Page of the Tab

I have got the following code to set the values of the EditText at the header bar (master flow) but it failes and no values are assigned.
Would you please tell me how setText ?
The below is my code
(My Master Activity)
#SuppressWarnings("deprecation")
public class MainActivity extends Activity
{
private AsyncTask <Void , Void, Void> mRegisterTask ;
private String userid;
private String orderid;
...
View inflatedView = getLayoutInflater().inflate(R.layout.activity_main, null);
final EditText s = (EditText) inflatedView.findViewById(R.id.textView2);
userid = "99999";
s.setText(userid);
activity_main
<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:layout_margin="0dp"
android:background="#drawable/bg_with_header"
android:padding="0dp"
tools:context=".MainActivity" >
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
android:padding="0dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
android:orientation="vertical"
android:padding="0dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="82dp"
android:layout_margin="0dp"
android:layout_marginRight="50dp"
android:orientation="horizontal"
android:padding="0dp" >
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:src="#drawable/header_tv1231231231231bnvlogo" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="82dp"
android:layout_gravity="center"
android:layout_toLeftOf="#+id/headerLogin"
android:scrollbars="none" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="300dp"
android:layout_height="86dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:showDividers="none"
android:tabStripEnabled="false" />
</HorizontalScrollView>
<RelativeLayout
android:id="#+id/headerLogin"
android:layout_width="wrap_content"
android:layout_height="82dp"
android:orientation="horizontal" >
<EditText
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/txtbg"
android:ems="10"
android:enabled="false"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding=" 5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#BDBDBD" />
<EditText
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/textView1"
android:background="#drawable/txtbg"
android:ems="10"
android:enabled="false"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#BDBDBD" />
<TextView
android:id="#+id/textVieasas2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textVieasas"
android:layout_alignBottom="#+id/textVieasas"
android:layout_toRightOf="#+id/textView2"
android:text="Last Login Date"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/textVieasas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignLeft="#+id/textView2"
android:text="Sales Code"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</RelativeLayout>
</LinearLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dp"
android:padding="0dp" />
</LinearLayout>
</TabHost>
you can also simple use this:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText s = (EditText) findViewById(R.id.textView2);
userid = "99999";
s.setText(userid);
}
Do this way
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText s = (EditText) findViewById(R.id.textView2);
userid = "99999";
s.setText(userid);
// or
View inflatedView = getLayoutInflater().inflate(R.layout.activity_main, null);
final EditText s = (EditText) inflatedView.findViewById(R.id.textView2);
userid = "99999";
s.setText(userid);
setContentView(inflatedView);
}

Categories

Resources